sqlspec 0.11.0__py3-none-any.whl → 0.11.1__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.
- sqlspec/adapters/adbc/driver.py +37 -60
- sqlspec/adapters/aiosqlite/driver.py +73 -104
- sqlspec/adapters/asyncmy/driver.py +28 -44
- sqlspec/adapters/asyncpg/driver.py +34 -44
- sqlspec/adapters/bigquery/driver.py +79 -168
- sqlspec/adapters/duckdb/driver.py +20 -49
- sqlspec/adapters/oracledb/driver.py +66 -86
- sqlspec/adapters/psqlpy/driver.py +39 -56
- sqlspec/adapters/psycopg/driver.py +71 -112
- sqlspec/adapters/sqlite/driver.py +15 -35
- sqlspec/base.py +0 -41
- sqlspec/filters.py +2 -1
- sqlspec/mixins.py +9 -10
- {sqlspec-0.11.0.dist-info → sqlspec-0.11.1.dist-info}/METADATA +4 -1
- {sqlspec-0.11.0.dist-info → sqlspec-0.11.1.dist-info}/RECORD +18 -18
- {sqlspec-0.11.0.dist-info → sqlspec-0.11.1.dist-info}/WHEEL +0 -0
- {sqlspec-0.11.0.dist-info → sqlspec-0.11.1.dist-info}/licenses/LICENSE +0 -0
- {sqlspec-0.11.0.dist-info → sqlspec-0.11.1.dist-info}/licenses/NOTICE +0 -0
|
@@ -8,17 +8,17 @@ from sqlglot import exp
|
|
|
8
8
|
from typing_extensions import TypeAlias
|
|
9
9
|
|
|
10
10
|
from sqlspec.base import AsyncDriverAdapterProtocol
|
|
11
|
+
from sqlspec.filters import StatementFilter
|
|
11
12
|
from sqlspec.mixins import ResultConverter, SQLTranslatorMixin
|
|
12
13
|
from sqlspec.statement import SQLStatement
|
|
13
14
|
|
|
14
15
|
if TYPE_CHECKING:
|
|
15
|
-
from collections.abc import Sequence
|
|
16
|
+
from collections.abc import Mapping, Sequence
|
|
16
17
|
|
|
17
18
|
from asyncpg import Record
|
|
18
19
|
from asyncpg.connection import Connection
|
|
19
20
|
from asyncpg.pool import PoolConnectionProxy
|
|
20
21
|
|
|
21
|
-
from sqlspec.filters import StatementFilter
|
|
22
22
|
from sqlspec.typing import ModelDTOT, StatementParameterType, T
|
|
23
23
|
|
|
24
24
|
__all__ = ("AsyncpgConnection", "AsyncpgDriver")
|
|
@@ -69,7 +69,6 @@ class AsyncpgDriver(
|
|
|
69
69
|
self,
|
|
70
70
|
sql: str,
|
|
71
71
|
parameters: "Optional[StatementParameterType]" = None,
|
|
72
|
-
/,
|
|
73
72
|
*filters: "StatementFilter",
|
|
74
73
|
**kwargs: Any,
|
|
75
74
|
) -> "tuple[str, Optional[Union[tuple[Any, ...], list[Any], dict[str, Any]]]]":
|
|
@@ -80,22 +79,33 @@ class AsyncpgDriver(
|
|
|
80
79
|
|
|
81
80
|
Args:
|
|
82
81
|
sql: SQL statement.
|
|
83
|
-
parameters: Query parameters.
|
|
82
|
+
parameters: Query parameters. Can be data or a StatementFilter.
|
|
84
83
|
*filters: Statement filters to apply.
|
|
85
84
|
**kwargs: Additional keyword arguments.
|
|
86
85
|
|
|
87
86
|
Returns:
|
|
88
87
|
Tuple of processed SQL and parameters.
|
|
89
88
|
"""
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
data_params_for_statement: Optional[Union[Mapping[str, Any], Sequence[Any]]] = None
|
|
90
|
+
combined_filters_list: list[StatementFilter] = list(filters)
|
|
91
|
+
|
|
92
|
+
if parameters is not None:
|
|
93
|
+
if isinstance(parameters, StatementFilter):
|
|
94
|
+
combined_filters_list.insert(0, parameters)
|
|
95
|
+
# data_params_for_statement remains None
|
|
96
|
+
else:
|
|
97
|
+
# If parameters is not a StatementFilter, it's actual data parameters.
|
|
98
|
+
data_params_for_statement = parameters
|
|
99
|
+
|
|
100
|
+
# Handle scalar parameter by converting to a single-item tuple if it's data
|
|
101
|
+
if data_params_for_statement is not None and not isinstance(data_params_for_statement, (list, tuple, dict)):
|
|
102
|
+
data_params_for_statement = (data_params_for_statement,)
|
|
93
103
|
|
|
94
104
|
# Create a SQLStatement with PostgreSQL dialect
|
|
95
|
-
statement = SQLStatement(sql,
|
|
105
|
+
statement = SQLStatement(sql, data_params_for_statement, kwargs=kwargs, dialect=self.dialect)
|
|
96
106
|
|
|
97
|
-
# Apply any filters
|
|
98
|
-
for filter_obj in
|
|
107
|
+
# Apply any filters from the combined list
|
|
108
|
+
for filter_obj in combined_filters_list:
|
|
99
109
|
statement = statement.apply_filter(filter_obj)
|
|
100
110
|
|
|
101
111
|
# Process the statement
|
|
@@ -164,7 +174,6 @@ class AsyncpgDriver(
|
|
|
164
174
|
self,
|
|
165
175
|
sql: str,
|
|
166
176
|
parameters: "Optional[StatementParameterType]" = None,
|
|
167
|
-
/,
|
|
168
177
|
*filters: "StatementFilter",
|
|
169
178
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
170
179
|
schema_type: None = None,
|
|
@@ -175,7 +184,6 @@ class AsyncpgDriver(
|
|
|
175
184
|
self,
|
|
176
185
|
sql: str,
|
|
177
186
|
parameters: "Optional[StatementParameterType]" = None,
|
|
178
|
-
/,
|
|
179
187
|
*filters: "StatementFilter",
|
|
180
188
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
181
189
|
schema_type: "type[ModelDTOT]",
|
|
@@ -185,7 +193,6 @@ class AsyncpgDriver(
|
|
|
185
193
|
self,
|
|
186
194
|
sql: str,
|
|
187
195
|
parameters: "Optional[StatementParameterType]" = None,
|
|
188
|
-
/,
|
|
189
196
|
*filters: "StatementFilter",
|
|
190
197
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
191
198
|
schema_type: "Optional[type[ModelDTOT]]" = None,
|
|
@@ -194,9 +201,9 @@ class AsyncpgDriver(
|
|
|
194
201
|
"""Fetch data from the database.
|
|
195
202
|
|
|
196
203
|
Args:
|
|
197
|
-
*filters: Statement filters to apply.
|
|
198
204
|
sql: SQL statement.
|
|
199
|
-
parameters: Query parameters.
|
|
205
|
+
parameters: Query parameters. Can be data or a StatementFilter.
|
|
206
|
+
*filters: Statement filters to apply.
|
|
200
207
|
connection: Optional connection to use.
|
|
201
208
|
schema_type: Optional schema class for the result.
|
|
202
209
|
**kwargs: Additional keyword arguments.
|
|
@@ -218,7 +225,6 @@ class AsyncpgDriver(
|
|
|
218
225
|
self,
|
|
219
226
|
sql: str,
|
|
220
227
|
parameters: "Optional[StatementParameterType]" = None,
|
|
221
|
-
/,
|
|
222
228
|
*filters: "StatementFilter",
|
|
223
229
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
224
230
|
schema_type: None = None,
|
|
@@ -229,7 +235,6 @@ class AsyncpgDriver(
|
|
|
229
235
|
self,
|
|
230
236
|
sql: str,
|
|
231
237
|
parameters: "Optional[StatementParameterType]" = None,
|
|
232
|
-
/,
|
|
233
238
|
*filters: "StatementFilter",
|
|
234
239
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
235
240
|
schema_type: "type[ModelDTOT]",
|
|
@@ -239,7 +244,6 @@ class AsyncpgDriver(
|
|
|
239
244
|
self,
|
|
240
245
|
sql: str,
|
|
241
246
|
parameters: "Optional[StatementParameterType]" = None,
|
|
242
|
-
/,
|
|
243
247
|
*filters: "StatementFilter",
|
|
244
248
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
245
249
|
schema_type: "Optional[type[ModelDTOT]]" = None,
|
|
@@ -248,9 +252,9 @@ class AsyncpgDriver(
|
|
|
248
252
|
"""Fetch one row from the database.
|
|
249
253
|
|
|
250
254
|
Args:
|
|
251
|
-
*filters: Statement filters to apply.
|
|
252
255
|
sql: SQL statement.
|
|
253
|
-
parameters: Query parameters.
|
|
256
|
+
parameters: Query parameters. Can be data or a StatementFilter.
|
|
257
|
+
*filters: Statement filters to apply.
|
|
254
258
|
connection: Optional connection to use.
|
|
255
259
|
schema_type: Optional schema class for the result.
|
|
256
260
|
**kwargs: Additional keyword arguments.
|
|
@@ -270,7 +274,6 @@ class AsyncpgDriver(
|
|
|
270
274
|
self,
|
|
271
275
|
sql: str,
|
|
272
276
|
parameters: "Optional[StatementParameterType]" = None,
|
|
273
|
-
/,
|
|
274
277
|
*filters: "StatementFilter",
|
|
275
278
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
276
279
|
schema_type: None = None,
|
|
@@ -281,7 +284,6 @@ class AsyncpgDriver(
|
|
|
281
284
|
self,
|
|
282
285
|
sql: str,
|
|
283
286
|
parameters: "Optional[StatementParameterType]" = None,
|
|
284
|
-
/,
|
|
285
287
|
*filters: "StatementFilter",
|
|
286
288
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
287
289
|
schema_type: "type[ModelDTOT]",
|
|
@@ -291,7 +293,6 @@ class AsyncpgDriver(
|
|
|
291
293
|
self,
|
|
292
294
|
sql: str,
|
|
293
295
|
parameters: "Optional[StatementParameterType]" = None,
|
|
294
|
-
/,
|
|
295
296
|
*filters: "StatementFilter",
|
|
296
297
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
297
298
|
schema_type: "Optional[type[ModelDTOT]]" = None,
|
|
@@ -300,9 +301,9 @@ class AsyncpgDriver(
|
|
|
300
301
|
"""Fetch one row from the database.
|
|
301
302
|
|
|
302
303
|
Args:
|
|
303
|
-
*filters: Statement filters to apply.
|
|
304
304
|
sql: SQL statement.
|
|
305
|
-
parameters: Query parameters.
|
|
305
|
+
parameters: Query parameters. Can be data or a StatementFilter.
|
|
306
|
+
*filters: Statement filters to apply.
|
|
306
307
|
connection: Optional connection to use.
|
|
307
308
|
schema_type: Optional schema class for the result.
|
|
308
309
|
**kwargs: Additional keyword arguments.
|
|
@@ -323,7 +324,6 @@ class AsyncpgDriver(
|
|
|
323
324
|
self,
|
|
324
325
|
sql: str,
|
|
325
326
|
parameters: "Optional[StatementParameterType]" = None,
|
|
326
|
-
/,
|
|
327
327
|
*filters: "StatementFilter",
|
|
328
328
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
329
329
|
schema_type: None = None,
|
|
@@ -334,7 +334,6 @@ class AsyncpgDriver(
|
|
|
334
334
|
self,
|
|
335
335
|
sql: str,
|
|
336
336
|
parameters: "Optional[StatementParameterType]" = None,
|
|
337
|
-
/,
|
|
338
337
|
*filters: "StatementFilter",
|
|
339
338
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
340
339
|
schema_type: "type[T]",
|
|
@@ -344,7 +343,6 @@ class AsyncpgDriver(
|
|
|
344
343
|
self,
|
|
345
344
|
sql: str,
|
|
346
345
|
parameters: "Optional[StatementParameterType]" = None,
|
|
347
|
-
/,
|
|
348
346
|
*filters: "StatementFilter",
|
|
349
347
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
350
348
|
schema_type: "Optional[type[T]]" = None,
|
|
@@ -353,9 +351,9 @@ class AsyncpgDriver(
|
|
|
353
351
|
"""Fetch a single value from the database.
|
|
354
352
|
|
|
355
353
|
Args:
|
|
356
|
-
*filters: Statement filters to apply.
|
|
357
354
|
sql: SQL statement.
|
|
358
|
-
parameters: Query parameters.
|
|
355
|
+
parameters: Query parameters. Can be data or a StatementFilter.
|
|
356
|
+
*filters: Statement filters to apply.
|
|
359
357
|
connection: Optional connection to use.
|
|
360
358
|
schema_type: Optional schema class for the result.
|
|
361
359
|
**kwargs: Additional keyword arguments.
|
|
@@ -377,7 +375,6 @@ class AsyncpgDriver(
|
|
|
377
375
|
self,
|
|
378
376
|
sql: str,
|
|
379
377
|
parameters: "Optional[StatementParameterType]" = None,
|
|
380
|
-
/,
|
|
381
378
|
*filters: "StatementFilter",
|
|
382
379
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
383
380
|
schema_type: None = None,
|
|
@@ -388,7 +385,6 @@ class AsyncpgDriver(
|
|
|
388
385
|
self,
|
|
389
386
|
sql: str,
|
|
390
387
|
parameters: "Optional[StatementParameterType]" = None,
|
|
391
|
-
/,
|
|
392
388
|
*filters: "StatementFilter",
|
|
393
389
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
394
390
|
schema_type: "type[T]",
|
|
@@ -398,7 +394,6 @@ class AsyncpgDriver(
|
|
|
398
394
|
self,
|
|
399
395
|
sql: str,
|
|
400
396
|
parameters: "Optional[StatementParameterType]" = None,
|
|
401
|
-
/,
|
|
402
397
|
*filters: "StatementFilter",
|
|
403
398
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
404
399
|
schema_type: "Optional[type[T]]" = None,
|
|
@@ -407,9 +402,9 @@ class AsyncpgDriver(
|
|
|
407
402
|
"""Fetch a single value from the database.
|
|
408
403
|
|
|
409
404
|
Args:
|
|
410
|
-
*filters: Statement filters to apply.
|
|
411
405
|
sql: SQL statement.
|
|
412
|
-
parameters: Query parameters.
|
|
406
|
+
parameters: Query parameters. Can be data or a StatementFilter.
|
|
407
|
+
*filters: Statement filters to apply.
|
|
413
408
|
connection: Optional connection to use.
|
|
414
409
|
schema_type: Optional schema class for the result.
|
|
415
410
|
**kwargs: Additional keyword arguments.
|
|
@@ -431,7 +426,6 @@ class AsyncpgDriver(
|
|
|
431
426
|
self,
|
|
432
427
|
sql: str,
|
|
433
428
|
parameters: "Optional[StatementParameterType]" = None,
|
|
434
|
-
/,
|
|
435
429
|
*filters: "StatementFilter",
|
|
436
430
|
connection: Optional["AsyncpgConnection"] = None,
|
|
437
431
|
**kwargs: Any,
|
|
@@ -439,9 +433,9 @@ class AsyncpgDriver(
|
|
|
439
433
|
"""Insert, update, or delete data from the database.
|
|
440
434
|
|
|
441
435
|
Args:
|
|
442
|
-
*filters: Statement filters to apply.
|
|
443
436
|
sql: SQL statement.
|
|
444
|
-
parameters: Query parameters.
|
|
437
|
+
parameters: Query parameters. Can be data or a StatementFilter.
|
|
438
|
+
*filters: Statement filters to apply.
|
|
445
439
|
connection: Optional connection to use.
|
|
446
440
|
**kwargs: Additional keyword arguments.
|
|
447
441
|
|
|
@@ -463,7 +457,6 @@ class AsyncpgDriver(
|
|
|
463
457
|
self,
|
|
464
458
|
sql: str,
|
|
465
459
|
parameters: "Optional[StatementParameterType]" = None,
|
|
466
|
-
/,
|
|
467
460
|
*filters: "StatementFilter",
|
|
468
461
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
469
462
|
schema_type: None = None,
|
|
@@ -474,7 +467,6 @@ class AsyncpgDriver(
|
|
|
474
467
|
self,
|
|
475
468
|
sql: str,
|
|
476
469
|
parameters: "Optional[StatementParameterType]" = None,
|
|
477
|
-
/,
|
|
478
470
|
*filters: "StatementFilter",
|
|
479
471
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
480
472
|
schema_type: "type[ModelDTOT]",
|
|
@@ -484,7 +476,6 @@ class AsyncpgDriver(
|
|
|
484
476
|
self,
|
|
485
477
|
sql: str,
|
|
486
478
|
parameters: "Optional[StatementParameterType]" = None,
|
|
487
|
-
/,
|
|
488
479
|
*filters: "StatementFilter",
|
|
489
480
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
490
481
|
schema_type: "Optional[type[ModelDTOT]]" = None,
|
|
@@ -493,9 +484,9 @@ class AsyncpgDriver(
|
|
|
493
484
|
"""Insert, update, or delete data from the database and return the affected row.
|
|
494
485
|
|
|
495
486
|
Args:
|
|
496
|
-
*filters: Statement filters to apply.
|
|
497
487
|
sql: SQL statement.
|
|
498
|
-
parameters: Query parameters.
|
|
488
|
+
parameters: Query parameters. Can be data or a StatementFilter.
|
|
489
|
+
*filters: Statement filters to apply.
|
|
499
490
|
connection: Optional connection to use.
|
|
500
491
|
schema_type: Optional schema class for the result.
|
|
501
492
|
**kwargs: Additional keyword arguments.
|
|
@@ -516,7 +507,6 @@ class AsyncpgDriver(
|
|
|
516
507
|
self,
|
|
517
508
|
sql: str,
|
|
518
509
|
parameters: "Optional[StatementParameterType]" = None,
|
|
519
|
-
/,
|
|
520
510
|
connection: "Optional[AsyncpgConnection]" = None,
|
|
521
511
|
**kwargs: Any,
|
|
522
512
|
) -> str:
|