data-factory-utils 2.2.0__tar.gz → 2.3.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: data-factory-utils
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Utility functions for interacting with data factories.
5
5
  Requires-Dist: boto3>=1.42.8
6
6
  Requires-Dist: boto3-stubs>=1.42.89
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "data-factory-utils"
3
- version = "2.2.0"
3
+ version = "2.3.0"
4
4
  description = "Utility functions for interacting with data factories."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -89,7 +89,7 @@ class WhereSetMembership(NamedTuple):
89
89
  """Config for WHERE IN comparisons."""
90
90
 
91
91
  col: str
92
- set: tuple[str]
92
+ set: tuple[str] | Subquery
93
93
  unquote: bool | None = False
94
94
  prefix: Literal["AND", "OR", "NOT"] | None = "AND"
95
95
  brackets: Literal["open", "close", "wrap"] | None = None
@@ -529,10 +529,14 @@ def _build_where_set_membership(config: WhereSetMembership) -> str:
529
529
  - WHERE NOT col IN (value, value)
530
530
  """
531
531
  validate_identifier(config.col)
532
- for value in config.set:
533
- validate_identifier(value)
532
+ if not isinstance(config.set, Subquery):
533
+ for value in config.set:
534
+ validate_identifier(value)
534
535
 
535
- if config.unquote:
536
+ if isinstance(config.set, Subquery):
537
+ values = str(config.set)
538
+ query_str = f"{config.col} IN {values}"
539
+ elif config.unquote:
536
540
  values = ", ".join(config.set)
537
541
  query_str = f"{config.col} IN ({values})"
538
542
  else:
@@ -733,8 +737,8 @@ class Query:
733
737
  msg = "WHERE statement has no valid conditions."
734
738
  raise ValueError(msg)
735
739
 
736
- # first condition cannot have prefix
737
- if i > 0 and condition.prefix:
740
+ # first condition cannot have prefix - unless it's "NOT"
741
+ if (i == 0 and condition.prefix == "NOT") or (i > 0 and condition.prefix):
738
742
  cond_str = f"{condition.prefix} {cond_str}"
739
743
 
740
744
  query_str.append(cond_str)