diff --git a/pycsw/ogc/fes/fes1.py b/pycsw/ogc/fes/fes1.py index d6268aa8e..2e443d84b 100644 --- a/pycsw/ogc/fes/fes1.py +++ b/pycsw/ogc/fes/fes1.py @@ -236,7 +236,6 @@ def _get_comparison_expression(elem): return expression queries = [] - queries_nested = [] values = [] LOGGER.debug('Scanning children elements') @@ -301,8 +300,10 @@ def _get_comparison_expression(elem): tagname = ' %s ' % child_tag_name.lower() if tagname in [' or ', ' and ']: # this is a nested binary logic query LOGGER.debug('Nested binary logic detected; operator=%s', tagname) + queries_nested = [] for child2 in child.xpath('child::*'): queries_nested.append(_get_comparison_expression(child2)) + LOGGER.debug('Nested binary logic queries: %s', queries_nested) queries.append('(%s)' % tagname.join(queries_nested)) else: queries.append(_get_comparison_expression(child)) diff --git a/pycsw/ogc/fes/fes2.py b/pycsw/ogc/fes/fes2.py index c38abf4e1..a29dcb946 100644 --- a/pycsw/ogc/fes/fes2.py +++ b/pycsw/ogc/fes/fes2.py @@ -254,7 +254,6 @@ def _get_comparison_expression(elem): return expression queries = [] - queries_nested = [] values = [] LOGGER.debug('Scanning children elements') @@ -319,8 +318,10 @@ def _get_comparison_expression(elem): tagname = ' %s ' % child_tag_name.lower() if tagname in [' or ', ' and ']: # this is a nested binary logic query LOGGER.debug('Nested binary logic detected; operator=%s', tagname) + queries_nested = [] for child2 in child.xpath('child::*'): queries_nested.append(_get_comparison_expression(child2)) + LOGGER.debug('Nested binary logic queries: %s', queries_nested) queries.append('(%s)' % tagname.join(queries_nested)) else: queries.append(_get_comparison_expression(child)) diff --git a/tests/functionaltests/suites/default/expected/post_GetRecords-filter-and-nested-or-multiple.xml b/tests/functionaltests/suites/default/expected/post_GetRecords-filter-and-nested-or-multiple.xml new file mode 100644 index 000000000..42fbc5950 --- /dev/null +++ b/tests/functionaltests/suites/default/expected/post_GetRecords-filter-and-nested-or-multiple.xml @@ -0,0 +1,19 @@ + + + + + + + urn:uuid:94bc9c83-97f6-4b40-9eb8-a8e8787a5c63 + http://purl.org/dc/dcmitype/Dataset + Mauris sed neque + Vegetation-Cropland + Curabitur lacinia, ante non porta tempus, mi lorem feugiat odio, eget suscipit eros pede ac velit. + 2006-03-26 + + 47.595 -4.097 + 51.217 0.889 + + + + diff --git a/tests/functionaltests/suites/default/post/GetRecords-filter-and-nested-or-multiple.xml b/tests/functionaltests/suites/default/post/GetRecords-filter-and-nested-or-multiple.xml new file mode 100644 index 000000000..3ab5276b5 --- /dev/null +++ b/tests/functionaltests/suites/default/post/GetRecords-filter-and-nested-or-multiple.xml @@ -0,0 +1,32 @@ + + + + full + + + + + + dc:type + http://purl.org/dc/dcmitype/Image + + + dc:type + http://purl.org/dc/dcmitype/Dataset + + + + + dc:title + Mauris% + + + dc:title + %neque + + + + + + +