oplnk-python-utils 1.1.8__tar.gz → 1.1.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {oplnk_python_utils-1.1.8/oplnk_python_utils.egg-info → oplnk_python_utils-1.1.9}/PKG-INFO +1 -1
  2. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/__init__.py +1 -1
  3. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/query/query_builder.py +40 -8
  4. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9/oplnk_python_utils.egg-info}/PKG-INFO +1 -1
  5. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/setup.py +1 -1
  6. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/LICENSE +0 -0
  7. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/MANIFEST.in +0 -0
  8. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/README.md +0 -0
  9. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/cache/__init__.py +0 -0
  10. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/cache/cache_utils.py +0 -0
  11. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/core/__init__.py +0 -0
  12. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/core/data.py +0 -0
  13. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/core/parsing.py +0 -0
  14. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/core/serialization.py +0 -0
  15. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/query/__init__.py +0 -0
  16. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils/reports/__init__.py +0 -0
  17. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils.egg-info/SOURCES.txt +0 -0
  18. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils.egg-info/dependency_links.txt +0 -0
  19. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils.egg-info/not-zip-safe +0 -0
  20. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils.egg-info/requires.txt +0 -0
  21. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/oplnk_python_utils.egg-info/top_level.txt +0 -0
  22. {oplnk_python_utils-1.1.8 → oplnk_python_utils-1.1.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oplnk-python-utils
3
- Version: 1.1.8
3
+ Version: 1.1.9
4
4
  Summary: Reusable utilities for caching, data manipulation, parsing, and MongoDB query building
5
5
  Home-page: https://github.com/openlinkspa/oplnk-python-utils
6
6
  Author: OpenLink SpA
@@ -7,7 +7,7 @@ from . import core
7
7
  from . import cache
8
8
  from . import query
9
9
 
10
- __version__ = "1.1.8"
10
+ __version__ = "1.1.9"
11
11
  __author__ = "OpenLink SpA"
12
12
 
13
13
  __all__ = ["core", "cache", "query", "reports", "__version__"]
@@ -1020,15 +1020,47 @@ class QueryBuilder:
1020
1020
 
1021
1021
  if "filters" in query:
1022
1022
  if not pipeline:
1023
- lookup_filters = {
1024
- field: value
1025
- for field, value in query["filters"].items()
1026
- if list(value.keys())[0][0] != "$"
1027
- }
1028
-
1029
- if list(lookup_filters.keys()):
1023
+ # Extract potential relation field names from filters, supporting
1024
+ # logical operators ($or/$and) and dot-notation (e.g., "company.name").
1025
+ def extract_relation_candidates(filters_dict):
1026
+ relation_names = set()
1027
+
1028
+ def walk(node):
1029
+ if isinstance(node, dict):
1030
+ for k, v in node.items():
1031
+ if k in ("$or", "$and"):
1032
+ # Value can be a list of conditions or a nested dict
1033
+ if isinstance(v, list):
1034
+ for item in v:
1035
+ walk(item)
1036
+ else:
1037
+ walk(v)
1038
+ else:
1039
+ # Field key: take root before dot and strip _id/_ids
1040
+ if (
1041
+ isinstance(k, str)
1042
+ and k
1043
+ and not k.startswith("$")
1044
+ ):
1045
+ root = k.split(".")[0]
1046
+ root = re.sub(r"(_ids|_id)$", "", root)
1047
+ if root:
1048
+ relation_names.add(root)
1049
+ # Continue walking nested structures like
1050
+ # {"company": {"name": {"$containsi": "x"}}}
1051
+ walk(v)
1052
+ elif isinstance(node, list):
1053
+ for item in node:
1054
+ walk(item)
1055
+ # Primitives are ignored
1056
+
1057
+ walk(filters_dict)
1058
+ return list(relation_names)
1059
+
1060
+ relation_candidates = extract_relation_candidates(query["filters"])
1061
+ if relation_candidates:
1030
1062
  populate_from_filters = self.get_count_lookup_relations(
1031
- list(lookup_filters.keys())
1063
+ relation_candidates
1032
1064
  )
1033
1065
  pipeline.extend(populate_from_filters)
1034
1066
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oplnk-python-utils
3
- Version: 1.1.8
3
+ Version: 1.1.9
4
4
  Summary: Reusable utilities for caching, data manipulation, parsing, and MongoDB query building
5
5
  Home-page: https://github.com/openlinkspa/oplnk-python-utils
6
6
  Author: OpenLink SpA
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="oplnk-python-utils",
5
- version="1.1.8",
5
+ version="1.1.9",
6
6
  author="OpenLink SpA",
7
7
  author_email="contacto@openlink.cl",
8
8
  description="Reusable utilities for caching, data manipulation, parsing, and MongoDB query building",