Skip to content

Commit 07682ec

Browse files
committed
update
1 parent 2e9e251 commit 07682ec

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

pycsw/core/repository.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -422,32 +422,22 @@ def query(self, constraint=None, sortby=None, typenames=None,
422422
maxrecords=10, startposition=0):
423423
''' Query records from underlying repository '''
424424

425-
# run the raw query and get total
426-
if self.database is not None:
427-
if 'where' in constraint: # GetRecords with constraint
428-
LOGGER.debug('constraint detected')
429-
query = self.session.query(self.dataset).filter(
430-
text(constraint['where'])).params(self._create_values(constraint['values']))
431-
else: # GetRecords sans constraint
432-
LOGGER.debug('No constraint detected')
433-
query = self.session.query(self.dataset)
434-
else:
435-
if constraint.get('ast') is not None: # GetRecords with pygeofilter AST
436-
LOGGER.debug('pygeofilter AST detected')
437-
LOGGER.debug('Transforming AST into filters')
438-
try:
439-
filters = to_filter(constraint['ast'], self.dbtype, self.query_mappings)
440-
LOGGER.debug(f'Filter: {filters}')
441-
except Exception as err:
442-
msg = f'AST evaluator error: {str(err)}'
443-
LOGGER.exception(msg)
444-
raise RuntimeError(msg)
425+
if constraint.get('ast') is not None: # GetRecords with pygeofilter AST
426+
LOGGER.debug('pygeofilter AST detected')
427+
LOGGER.debug('Transforming AST into filters')
428+
try:
429+
filters = to_filter(constraint['ast'], self.dbtype, self.query_mappings)
430+
LOGGER.debug(f'Filter: {filters}')
431+
except Exception as err:
432+
msg = f'AST evaluator error: {str(err)}'
433+
LOGGER.exception(msg)
434+
raise RuntimeError(msg)
445435

446-
query = self.session.query(self.dataset).filter(filters)
436+
query = self.session.query(self.dataset).filter(filters)
447437

448-
else: # GetRecords sans pygeofilter AST
449-
LOGGER.debug('No pygeofilter AST detected')
450-
query = self.session.query(self.dataset)
438+
else: # GetRecords sans pygeofilter AST
439+
LOGGER.debug('No pygeofilter AST detected')
440+
query = self.session.query(self.dataset)
451441

452442
total = self._get_repo_filter(query).count()
453443

pycsw/ogc/api/records.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,9 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'):
760760
else:
761761
ast = None
762762

763-
count, records = self.repository.query(ast=ast, sortby=sortby, maxrecords=limit, startposition=offset)
763+
count, records = self.repository.query(
764+
constraint={'ast': ast}, sortby=sortby, maxrecords=limit,
765+
startposition=offset)
764766

765767
if facets_requested:
766768
LOGGER.debug('Running facet query')

0 commit comments

Comments
 (0)