Skip to content

Commit

Permalink
Merge further tweaks from feature/dbio-exp-search into test/beta1a
Browse files Browse the repository at this point in the history
  • Loading branch information
RayPlante committed May 6, 2024
2 parents 7e87241 + d3fbafd commit 658684b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions python/nistoar/midas/dbio/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,13 +1010,15 @@ def get_record_for(self, id: str, perm: str = ACLs.READ) -> ProjectRecord:
if not out.authorized(perm):
raise NotAuthorized(self.user_id, perm)
return out

def check_query_structure(query):

@classmethod
def check_query_structure(cls, query):
if not isinstance(query, dict):
return False

valid_operators = ['$and', '$or', '$not', '$nor', '$eq', '$ne', '$gt', '$gte', '$lt', '$lte', '$in', '$nin', '$exists', '$type', '$expr', '$jsonSchema', '$mod', '$regex', '$text',
'$where', '$geoIntersects', '$geoWithin', '$near', '$nearSphere', '$all', '$elemMatch', '$size', '$bitsAllClear', '$bitsAllSet', '$bitsAnyClear', '$bitsAnySet', '$comment', '$meta']
valid_operators = ['$and', '$or', '$not', '$nor', '$eq', '$ne', '$gt', '$gte', '$lt',
'$lte', '$in', '$nin', '$exists', '$type', '$mod', '$regex', '$text',
'$all', '$elemMatch', '$size']

for key in query.keys():
if key not in valid_operators:
Expand Down
2 changes: 1 addition & 1 deletion python/nistoar/midas/dbio/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def select_records(self, perm: base.Permissions=base.ACLs.OWN, **cnsts) -> Itera

def adv_select_records(self, filter: dict,
perm: base.Permissions=base.ACLs.OWN) -> Iterator[base.ProjectRecord]:
if(base.DBClient.check_query_structure(filter) == True):
if base.DBClient.check_query_structure(filter):
if isinstance(perm, str):
perm = [perm]
if isinstance(perm, (list, tuple)):
Expand Down

0 comments on commit 658684b

Please sign in to comment.