Ver código fonte

added support for ogc:PropertyIsNull in ogc:Filter

Piotr Labudda 10 anos atrás
pai
commit
b4e373ad3d

+ 6 - 0
SE/schema/wfs/convertOgcFilterToXmlTaskList.xsl

@@ -72,4 +72,10 @@
 		</xsl:element>
 	</xsl:template>
 
+	<xsl:template match="ogc:PropertyIsNull">
+		<xsl:element name="sql_filter_comparisonFieldIsNull">
+			<xsl:attribute name="fieldName"><xsl:value-of select="ogc:PropertyName" /></xsl:attribute>
+		</xsl:element>
+	</xsl:template>
+
 </xsl:stylesheet>

+ 5 - 0
SE/se-lib/ParseOgcFilter.php

@@ -104,6 +104,11 @@ OGC_FILTER_XML_FILE;
 					$queryWhereBuilder->addComparisonFieldToValue($fieldName, $comparisonSign, $value);
 				}
 					break;
+				case 'sql_filter_comparisonFieldIsNull': {
+					$fieldName = V::get('fieldName', '', $tag['attributes']);
+					$queryWhereBuilder->sql_filter_comparisonFieldIsNull($fieldName);
+				}
+					break;
 				case 'sql_filter_openBlock': {
 					$blockType = V::get('type', '', $tag['attributes']);
 					DBG::_('DBG_DS_OGC', '>2', "sql_filter_openBlock block Type {$blockType} attrs", json_encode($tag), __CLASS__, __FUNCTION__, __LINE__);

+ 11 - 0
SE/se-lib/SqlQueryWhereBuilder.php

@@ -29,6 +29,10 @@ class SqlQueryWhereBuilder {
 		$this->_log[] = array('comparisonFieldToValue', $fieldName, $sqlCompSign, $value);
 	}
 
+	public function sql_filter_comparisonFieldIsNull($fieldName) {
+		$this->_log[] = array('comparisonFieldIsNull', $fieldName);
+	}
+
 	public function getQueryWhere($tablePrefix = '') {
 		$sqlWhereRaw = $this->parseQueryWhere();
 		$sqlTablePrefix = ($tablePrefix)? "`{$tablePrefix}`." : '';
@@ -102,6 +106,13 @@ class SqlQueryWhereBuilder {
 						array_push($sqlValuesStack, $stackValue);
 //echo "L.".__LINE__.":sqlBlocksStack:" . json_encode($sqlBlocksStack) . "\n";
 //echo "L.".__LINE__.":sqlValuesStack:" . json_encode($sqlValuesStack) . "\n\n";
+					} else if (is_array($log) && 2 == count($log) && 'comparisonFieldIsNull' == $log[0]) {
+						$sqlFieldName = $log[1];
+						$sqlFromStack = "{tablePrefix}`{$sqlFieldName}` is null";
+						$stackValue = array_pop($sqlValuesStack);
+						if (!is_array($stackValue)) throw new Exception("parse sql query failed - stack value is not array");
+						array_push($stackValue, $sqlFromStack);
+						array_push($sqlValuesStack, $stackValue);
 					} else {
 						throw new Exception("parse sql query failed - unknown '" . json_encode($log) . "'");
 					}