oplnk-python-utils 1.1.2__tar.gz → 1.1.4__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.1.2/oplnk_python_utils.egg-info → oplnk_python_utils-1.1.4}/PKG-INFO +1 -1
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/__init__.py +1 -1
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/query/query_builder.py +24 -4
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4/oplnk_python_utils.egg-info}/PKG-INFO +1 -1
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/setup.py +1 -1
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/LICENSE +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/MANIFEST.in +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/README.md +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/cache/__init__.py +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/cache/cache_utils.py +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/__init__.py +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/data.py +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/parsing.py +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/serialization.py +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/query/__init__.py +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/SOURCES.txt +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/dependency_links.txt +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/not-zip-safe +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/requires.txt +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/top_level.txt +0 -0
- {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/setup.cfg +0 -0
{oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/query/query_builder.py
RENAMED
|
@@ -617,12 +617,31 @@ class QueryBuilder:
|
|
|
617
617
|
try:
|
|
618
618
|
# Build group_id with proper field expressions
|
|
619
619
|
group_id = {}
|
|
620
|
+
project_fields = {}
|
|
621
|
+
|
|
620
622
|
for field in distinct_params:
|
|
621
623
|
try:
|
|
622
624
|
# Use utility function to build proper aggregation expression
|
|
623
625
|
field_expression = build_aggregation_field_expression(field)
|
|
624
|
-
|
|
625
|
-
|
|
626
|
+
|
|
627
|
+
# For MongoDB $group stage, we need to use a safe key name (no dots)
|
|
628
|
+
# We'll use the original field name as key, but replace dots with underscores for the group
|
|
629
|
+
safe_key = (
|
|
630
|
+
field.replace(".", "_").replace("[", "_").replace("]", "_")
|
|
631
|
+
)
|
|
632
|
+
group_id[safe_key] = field_expression
|
|
633
|
+
|
|
634
|
+
# Build nested structure for the projection to maintain original field structure
|
|
635
|
+
parts = field.split(".")
|
|
636
|
+
current = project_fields
|
|
637
|
+
for i, part in enumerate(parts[:-1]):
|
|
638
|
+
if part not in current:
|
|
639
|
+
current[part] = {}
|
|
640
|
+
current = current[part]
|
|
641
|
+
|
|
642
|
+
# Set the final value
|
|
643
|
+
current[parts[-1]] = f"$_id.{safe_key}"
|
|
644
|
+
|
|
626
645
|
except ValueError as e:
|
|
627
646
|
# Log error and skip invalid field
|
|
628
647
|
print(f"Warning: Skipping invalid field '{field}' in distinct: {e}")
|
|
@@ -634,8 +653,9 @@ class QueryBuilder:
|
|
|
634
653
|
group_stage = {"$group": {"_id": group_id}}
|
|
635
654
|
|
|
636
655
|
if include_project:
|
|
637
|
-
|
|
638
|
-
|
|
656
|
+
# Use $project to create the nested structure
|
|
657
|
+
project_stage = {"$project": project_fields}
|
|
658
|
+
return [group_stage, project_stage]
|
|
639
659
|
else:
|
|
640
660
|
return [group_stage]
|
|
641
661
|
|
|
@@ -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.
|
|
5
|
+
version="1.1.4",
|
|
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.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/cache/cache_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/serialization.py
RENAMED
|
File without changes
|
|
File without changes
|
{oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/requires.txt
RENAMED
|
File without changes
|
{oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|