sqlspec 0.24.1__py3-none-any.whl → 0.25.0__py3-none-any.whl

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.

Potentially problematic release.


This version of sqlspec might be problematic. Click here for more details.

Files changed (42) hide show
  1. sqlspec/_sql.py +11 -15
  2. sqlspec/_typing.py +2 -0
  3. sqlspec/adapters/adbc/driver.py +2 -2
  4. sqlspec/adapters/oracledb/driver.py +5 -0
  5. sqlspec/adapters/psycopg/config.py +2 -4
  6. sqlspec/base.py +3 -4
  7. sqlspec/builder/_base.py +55 -13
  8. sqlspec/builder/_column.py +9 -0
  9. sqlspec/builder/_ddl.py +7 -7
  10. sqlspec/builder/_insert.py +10 -6
  11. sqlspec/builder/_parsing_utils.py +23 -4
  12. sqlspec/builder/_update.py +1 -1
  13. sqlspec/builder/mixins/_cte_and_set_ops.py +31 -22
  14. sqlspec/builder/mixins/_delete_operations.py +12 -7
  15. sqlspec/builder/mixins/_insert_operations.py +50 -36
  16. sqlspec/builder/mixins/_join_operations.py +1 -0
  17. sqlspec/builder/mixins/_merge_operations.py +54 -28
  18. sqlspec/builder/mixins/_order_limit_operations.py +1 -0
  19. sqlspec/builder/mixins/_pivot_operations.py +1 -0
  20. sqlspec/builder/mixins/_select_operations.py +42 -14
  21. sqlspec/builder/mixins/_update_operations.py +30 -18
  22. sqlspec/builder/mixins/_where_clause.py +48 -60
  23. sqlspec/core/__init__.py +3 -2
  24. sqlspec/core/cache.py +297 -351
  25. sqlspec/core/compiler.py +5 -3
  26. sqlspec/core/filters.py +246 -213
  27. sqlspec/core/hashing.py +9 -11
  28. sqlspec/core/parameters.py +20 -7
  29. sqlspec/core/statement.py +67 -12
  30. sqlspec/driver/_async.py +2 -2
  31. sqlspec/driver/_common.py +31 -14
  32. sqlspec/driver/_sync.py +2 -2
  33. sqlspec/driver/mixins/_result_tools.py +60 -7
  34. sqlspec/loader.py +8 -9
  35. sqlspec/storage/backends/fsspec.py +1 -0
  36. sqlspec/typing.py +2 -0
  37. {sqlspec-0.24.1.dist-info → sqlspec-0.25.0.dist-info}/METADATA +1 -1
  38. {sqlspec-0.24.1.dist-info → sqlspec-0.25.0.dist-info}/RECORD +42 -42
  39. {sqlspec-0.24.1.dist-info → sqlspec-0.25.0.dist-info}/WHEEL +0 -0
  40. {sqlspec-0.24.1.dist-info → sqlspec-0.25.0.dist-info}/entry_points.txt +0 -0
  41. {sqlspec-0.24.1.dist-info → sqlspec-0.25.0.dist-info}/licenses/LICENSE +0 -0
  42. {sqlspec-0.24.1.dist-info → sqlspec-0.25.0.dist-info}/licenses/NOTICE +0 -0
sqlspec/core/compiler.py CHANGED
@@ -171,7 +171,7 @@ class SQLProcessor:
171
171
  if not self._config.enable_caching:
172
172
  return self._compile_uncached(sql, parameters, is_many)
173
173
 
174
- cache_key = self._make_cache_key(sql, parameters)
174
+ cache_key = self._make_cache_key(sql, parameters, is_many)
175
175
 
176
176
  if cache_key in self._cache:
177
177
  result = self._cache[cache_key]
@@ -216,7 +216,7 @@ class SQLProcessor:
216
216
  if self._config.parameter_config.needs_static_script_compilation and processed_params is None:
217
217
  sqlglot_sql = processed_sql
218
218
  else:
219
- sqlglot_sql, _ = self._parameter_processor._get_sqlglot_compatible_sql(
219
+ sqlglot_sql, _ = self._parameter_processor.get_sqlglot_compatible_sql(
220
220
  sql, parameters, self._config.parameter_config, dialect_str
221
221
  )
222
222
 
@@ -273,12 +273,13 @@ class SQLProcessor:
273
273
  logger.warning("Compilation failed, using fallback: %s", e)
274
274
  return CompiledSQL(compiled_sql=sql, execution_parameters=parameters, operation_type="UNKNOWN")
275
275
 
276
- def _make_cache_key(self, sql: str, parameters: Any) -> str:
276
+ def _make_cache_key(self, sql: str, parameters: Any, is_many: bool = False) -> str:
277
277
  """Generate cache key.
278
278
 
279
279
  Args:
280
280
  sql: SQL string
281
281
  parameters: Parameter values
282
+ is_many: Whether this is for execute_many operation
282
283
 
283
284
  Returns:
284
285
  Cache key string
@@ -295,6 +296,7 @@ class SQLProcessor:
295
296
  dialect_str,
296
297
  self._config.enable_parsing,
297
298
  self._config.enable_transformations,
299
+ is_many,
298
300
  )
299
301
 
300
302
  hash_str = hashlib.sha256(str(hash_data).encode("utf-8")).hexdigest()[:16]