oplnk-python-utils 1.1.3__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.3/oplnk_python_utils.egg-info → oplnk_python_utils-1.1.4}/PKG-INFO +1 -1
  2. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils/__init__.py +1 -1
  3. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils/query/query_builder.py +19 -15
  4. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4/oplnk_python_utils.egg-info}/PKG-INFO +1 -1
  5. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/setup.py +1 -1
  6. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/LICENSE +0 -0
  7. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/MANIFEST.in +0 -0
  8. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/README.md +0 -0
  9. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils/cache/__init__.py +0 -0
  10. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils/cache/cache_utils.py +0 -0
  11. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/__init__.py +0 -0
  12. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/data.py +0 -0
  13. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/parsing.py +0 -0
  14. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils/core/serialization.py +0 -0
  15. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils/query/__init__.py +0 -0
  16. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/SOURCES.txt +0 -0
  17. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/dependency_links.txt +0 -0
  18. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/not-zip-safe +0 -0
  19. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/requires.txt +0 -0
  20. {oplnk_python_utils-1.1.3 → oplnk_python_utils-1.1.4}/oplnk_python_utils.egg-info/top_level.txt +0 -0
  21. {oplnk_python_utils-1.1.3 → 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.3
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.3"
10
+ __version__ = "1.1.4"
11
11
  __author__ = "OpenLink SpA"
12
12
 
13
13
  __all__ = ["core", "cache", "query", "__version__"]
@@ -617,27 +617,30 @@ 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
626
 
625
- # Create nested structure for fields with dot notation
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
626
635
  parts = field.split(".")
627
- d = group_id
636
+ current = project_fields
628
637
  for i, part in enumerate(parts[:-1]):
629
- # If a non-dict value is at the path, it can't be extended
630
- if part in d and not isinstance(d[part], dict):
631
- # To avoid overwriting, you could add a unique suffix, or handle as an error
632
- # For now, let's just print a warning and continue
633
- print(
634
- f"Warning: conflicting path in distinct fields for '{field}' at part '{part}'."
635
- )
636
- d = d.setdefault(f"{part}_{i}", {})
637
- else:
638
- d = d.setdefault(part, {})
638
+ if part not in current:
639
+ current[part] = {}
640
+ current = current[part]
639
641
 
640
- d[parts[-1]] = field_expression
642
+ # Set the final value
643
+ current[parts[-1]] = f"$_id.{safe_key}"
641
644
 
642
645
  except ValueError as e:
643
646
  # Log error and skip invalid field
@@ -650,8 +653,9 @@ class QueryBuilder:
650
653
  group_stage = {"$group": {"_id": group_id}}
651
654
 
652
655
  if include_project:
653
- replace_root_stage = {"$replaceRoot": {"newRoot": "$_id"}}
654
- 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]
655
659
  else:
656
660
  return [group_stage]
657
661
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oplnk-python-utils
3
- Version: 1.1.3
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.3",
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",