@@ -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
0 commit comments