oplnk-python-utils 1.2.4__tar.gz → 1.2.5__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.
- {oplnk_python_utils-1.2.4/oplnk_python_utils.egg-info → oplnk_python_utils-1.2.5}/PKG-INFO +1 -1
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/__init__.py +1 -1
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/query/query_builder.py +38 -9
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5/oplnk_python_utils.egg-info}/PKG-INFO +1 -1
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/setup.py +1 -1
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/LICENSE +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/MANIFEST.in +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/README.md +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/cache/__init__.py +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/cache/cache_utils.py +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/core/__init__.py +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/core/data.py +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/core/parsing.py +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/core/serialization.py +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/query/__init__.py +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/reports/__init__.py +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils.egg-info/SOURCES.txt +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils.egg-info/dependency_links.txt +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils.egg-info/not-zip-safe +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils.egg-info/requires.txt +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils.egg-info/top_level.txt +0 -0
- {oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/setup.cfg +0 -0
{oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/query/query_builder.py
RENAMED
|
@@ -871,27 +871,56 @@ class QueryBuilder:
|
|
|
871
871
|
meta_result = {"totalCount": 0}
|
|
872
872
|
|
|
873
873
|
# Sanitize populate fields: remove original ID fields when populated (unless requested in fields)
|
|
874
|
+
# Also ensure populated fields return null if lookup failed (instead of missing)
|
|
874
875
|
if "populate" in query and isinstance(data_result, list):
|
|
875
876
|
fields_requested = query.get("fields", [])
|
|
876
877
|
populated_fields = self._get_populated_fields_list(query["populate"])
|
|
877
878
|
|
|
878
879
|
for doc in data_result:
|
|
879
|
-
# For audit fields
|
|
880
|
+
# For audit fields
|
|
880
881
|
for field_name, field_config in RESERVED_AUDIT_FIELDS.items():
|
|
881
882
|
if field_name in populated_fields:
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
883
|
+
alias = field_config["alias"]
|
|
884
|
+
original_exists = field_name in doc
|
|
885
|
+
alias_exists = alias in doc
|
|
886
|
+
|
|
887
|
+
# If populate was requested but alias doesn't exist, set to null
|
|
888
|
+
# (only if the original field exists - meaning the field is part of the document)
|
|
889
|
+
if not alias_exists and original_exists:
|
|
890
|
+
doc[alias] = None
|
|
891
|
+
|
|
892
|
+
# Remove original field if not explicitly requested in fields
|
|
893
|
+
if alias_exists and field_name not in fields_requested:
|
|
894
|
+
if original_exists:
|
|
888
895
|
del doc[field_name]
|
|
889
896
|
|
|
890
|
-
# For normal relations
|
|
897
|
+
# For normal relations
|
|
891
898
|
for populated_field in populated_fields:
|
|
892
899
|
if populated_field not in RESERVED_AUDIT_FIELDS:
|
|
893
|
-
#
|
|
900
|
+
# Find the ID field and alias for this relation
|
|
894
901
|
id_field = self._get_id_field_for_relation(populated_field)
|
|
902
|
+
|
|
903
|
+
# Determine the alias (same as base name or custom alias)
|
|
904
|
+
alias = populated_field
|
|
905
|
+
for relation in self.relations:
|
|
906
|
+
relation_name = relation[1]
|
|
907
|
+
base_name = relation_name.replace("_ids", "").replace(
|
|
908
|
+
"_id", ""
|
|
909
|
+
)
|
|
910
|
+
if base_name == populated_field:
|
|
911
|
+
# Use custom alias if provided (5th element)
|
|
912
|
+
if len(relation) > 4 and relation[4]:
|
|
913
|
+
alias = relation[4]
|
|
914
|
+
break
|
|
915
|
+
|
|
916
|
+
original_exists = id_field and id_field in doc
|
|
917
|
+
alias_exists = alias in doc
|
|
918
|
+
|
|
919
|
+
# If populate was requested but alias doesn't exist, set to null
|
|
920
|
+
if not alias_exists and original_exists:
|
|
921
|
+
doc[alias] = None
|
|
922
|
+
|
|
923
|
+
# Remove original ID field if not explicitly requested in fields
|
|
895
924
|
if id_field and id_field not in fields_requested:
|
|
896
925
|
if id_field in doc:
|
|
897
926
|
del doc[id_field]
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="oplnk-python-utils",
|
|
5
|
-
version="1.2.
|
|
5
|
+
version="1.2.5",
|
|
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",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/cache/cache_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/core/serialization.py
RENAMED
|
File without changes
|
|
File without changes
|
{oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils/reports/__init__.py
RENAMED
|
File without changes
|
{oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils.egg-info/requires.txt
RENAMED
|
File without changes
|
{oplnk_python_utils-1.2.4 → oplnk_python_utils-1.2.5}/oplnk_python_utils.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|