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.
Files changed (21) hide show
  1. {oplnk_python_utils-1.1.2/oplnk_python_utils.egg-info → oplnk_python_utils-1.1.4}/PKG-INFO +1 -1
  2. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/__init__.py +1 -1
  3. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/query/query_builder.py +24 -4
  4. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4/oplnk_python_utils.egg-info}/PKG-INFO +1 -1
  5. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/setup.py +1 -1
  6. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/LICENSE +0 -0
  7. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/MANIFEST.in +0 -0
  8. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/README.md +0 -0
  9. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/cache/__init__.py +0 -0
  10. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/cache/cache_utils.py +0 -0
  11. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/__init__.py +0 -0
  12. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/data.py +0 -0
  13. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/parsing.py +0 -0
  14. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/serialization.py +0 -0
  15. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils/query/__init__.py +0 -0
  16. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/SOURCES.txt +0 -0
  17. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/dependency_links.txt +0 -0
  18. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/not-zip-safe +0 -0
  19. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/requires.txt +0 -0
  20. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/top_level.txt +0 -0
  21. {oplnk_python_utils-1.1.2 → oplnk_python_utils-1.1.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oplnk-python-utils
3
- Version: 1.1.2
3
+ Version: 1.1.4
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.2"
10
+ __version__ = "1.1.4"
11
11
  __author__ = "OpenLink SpA"
12
12
 
13
13
  __all__ = ["core", "cache", "query", "__version__"]
@@ -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
- # Use original field name as key for the result
625
- group_id[field] = field_expression
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
- replace_root_stage = {"$replaceRoot": {"newRoot": "$_id"}}
638
- return [group_stage, replace_root_stage]
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oplnk-python-utils
3
- Version: 1.1.2
3
+ Version: 1.1.4
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.2",
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",