Mercurial > libervia-backend
comparison sat/memory/sqla.py @ 3754:af485e8afe03
core (memory/sqla): `searchPubsubItems` can now filter on item names
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 13 May 2022 18:02:37 +0200 |
parents | 10b71e3526bd |
children | cc653b2685f0 |
comparison
equal
deleted
inserted
replaced
3753:10b71e3526bd | 3754:af485e8afe03 |
---|---|
1423 filter on nodes with those types. None can be used to filter on nodes with | 1423 filter on nodes with those types. None can be used to filter on nodes with |
1424 no type set | 1424 no type set |
1425 :subtypes (list[str|None]): | 1425 :subtypes (list[str|None]): |
1426 filter on nodes with those subtypes. None can be used to filter on nodes with | 1426 filter on nodes with those subtypes. None can be used to filter on nodes with |
1427 no subtype set | 1427 no subtype set |
1428 :names (list[str]): | |
1429 filter on items with those names | |
1428 :parsed (list[dict]): | 1430 :parsed (list[dict]): |
1429 Filter on a parsed data field. The dict must contain 3 keys: ``path`` | 1431 Filter on a parsed data field. The dict must contain 3 keys: ``path`` |
1430 which is a list of str or int giving the path to the field of interest | 1432 which is a list of str or int giving the path to the field of interest |
1431 (str for a dict key, int for a list index), ``operator`` with indicate the | 1433 (str for a dict key, int for a list index), ``operator`` with indicate the |
1432 operator to use to check the condition, and ``value`` which depends of | 1434 operator to use to check the condition, and ``value`` which depends of |
1508 else: | 1510 else: |
1509 condition = getattr(PubsubNode, attr).in_(value) | 1511 condition = getattr(PubsubNode, attr).in_(value) |
1510 stmt = stmt.where(condition) | 1512 stmt = stmt.where(condition) |
1511 else: | 1513 else: |
1512 stmt = stmt.options(selectinload(PubsubItem.node)) | 1514 stmt = stmt.options(selectinload(PubsubItem.node)) |
1515 | |
1516 # names | |
1517 names = query.get("names") | |
1518 if names: | |
1519 stmt = stmt.where(PubsubItem.name.in_(names)) | |
1513 | 1520 |
1514 # parsed data filters | 1521 # parsed data filters |
1515 parsed = query.get("parsed", []) | 1522 parsed = query.get("parsed", []) |
1516 for filter_ in parsed: | 1523 for filter_ in parsed: |
1517 try: | 1524 try: |