sqlobjects 1.6.0__tar.gz → 1.7.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.
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/CHANGELOG.md +10 -0
- {sqlobjects-1.6.0/sqlobjects.egg-info → sqlobjects-1.7.0}/PKG-INFO +1 -1
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/pyproject.toml +1 -1
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/function.py +45 -8
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/types/comparators.py +8 -2
- {sqlobjects-1.6.0 → sqlobjects-1.7.0/sqlobjects.egg-info}/PKG-INFO +1 -1
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/LICENSE +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/README.md +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/docs/rules/01-database-session-guide.md +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/docs/rules/02-model-definition-guide.md +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/docs/rules/03-query-operations-guide.md +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/docs/rules/04-crud-operations-guide.md +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/docs/rules/05-relationships-guide.md +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/docs/rules/06-validation-signals-guide.md +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/docs/rules/07-performance-guide.md +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/docs/rules/README.md +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/setup.cfg +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/_install_rules.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/cascade.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/contrib/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/contrib/asgi.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/contrib/fastapi.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/database/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/database/config.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/database/manager.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/exceptions.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/aggregate.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/base.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/cte.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/explain.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/mixins.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/scalar.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/subquery.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/terminal.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/expressions/window.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/core.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/functions.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/proxies.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/relations/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/relations/descriptors.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/relations/managers.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/relations/prefetch.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/relations/strategies.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/relations/utils.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/shortcuts.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/types/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/types/base.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/types/registry.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/fields/utils.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/internal/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/internal/operations.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/internal/results.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/metadata.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/mixins.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/model.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/objects/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/objects/bulk.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/objects/core.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/objects/upsert.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/queries/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/queries/builder.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/queries/dialect.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/queries/executor.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/queryset.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/session.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/signals.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/utils/__init__.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/utils/inspect.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/utils/naming.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/utils/pattern.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects/validators.py +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects.egg-info/SOURCES.txt +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects.egg-info/dependency_links.txt +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects.egg-info/entry_points.txt +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects.egg-info/requires.txt +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/sqlobjects.egg-info/top_level.txt +0 -0
- {sqlobjects-1.6.0 → sqlobjects-1.7.0}/tests/test_config.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlobjects
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Django-style async ORM library based on SQLAlchemy with chainable queries, Q objects, and relationship loading
|
|
5
5
|
Author-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
|
|
6
6
|
Maintainer-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
|
|
@@ -183,7 +183,9 @@ class FunctionExpression:
|
|
|
183
183
|
|
|
184
184
|
Args:
|
|
185
185
|
sql: Raw SQL function name or expression
|
|
186
|
-
*args: Arguments to pass to the function. Use ... (Ellipsis) as placeholder for current expression
|
|
186
|
+
*args: Arguments to pass to the function. Use ... (Ellipsis) as placeholder for current expression.
|
|
187
|
+
SQLAlchemy expressions (ColumnElement, FunctionExpression) are passed through as-is;
|
|
188
|
+
plain Python values are wrapped with literal().
|
|
187
189
|
**kwargs: Additional keyword arguments passed to the function
|
|
188
190
|
|
|
189
191
|
Returns:
|
|
@@ -198,12 +200,17 @@ class FunctionExpression:
|
|
|
198
200
|
User.age.avg().raw('CUSTOM_FUNCTION', 'param1', ..., 'param2')
|
|
199
201
|
# Generates: CUSTOM_FUNCTION('param1', avg(age), 'param2')
|
|
200
202
|
|
|
201
|
-
#
|
|
202
|
-
User.
|
|
203
|
-
# Generates: CUSTOM_FUNCTION(
|
|
203
|
+
# Passing another SA expression as argument
|
|
204
|
+
User.name.raw('CUSTOM_FUNCTION', other_func_expr)
|
|
205
|
+
# Generates: CUSTOM_FUNCTION(name, other_func_expr)
|
|
204
206
|
"""
|
|
205
207
|
from sqlalchemy import literal
|
|
206
208
|
|
|
209
|
+
def _to_sql_arg(arg):
|
|
210
|
+
if isinstance(arg, (ColumnElement, FunctionExpression)):
|
|
211
|
+
return arg
|
|
212
|
+
return literal(arg)
|
|
213
|
+
|
|
207
214
|
# Check if ... (Ellipsis) is used as placeholder
|
|
208
215
|
if ... in args:
|
|
209
216
|
# Replace ... with current expression
|
|
@@ -212,12 +219,10 @@ class FunctionExpression:
|
|
|
212
219
|
if arg is ...:
|
|
213
220
|
all_args.append(self.expression)
|
|
214
221
|
else:
|
|
215
|
-
all_args.append(
|
|
222
|
+
all_args.append(_to_sql_arg(arg))
|
|
216
223
|
else:
|
|
217
224
|
# Default behavior: current expression as first argument
|
|
218
|
-
all_args = [self.expression]
|
|
219
|
-
for arg in args:
|
|
220
|
-
all_args.append(literal(arg))
|
|
225
|
+
all_args = [self.expression] + [_to_sql_arg(arg) for arg in args]
|
|
221
226
|
|
|
222
227
|
# Use func to create the raw function call
|
|
223
228
|
raw_func = getattr(_sa_func, sql)
|
|
@@ -425,6 +430,38 @@ class _FuncWrapper:
|
|
|
425
430
|
|
|
426
431
|
def nth_value(self, col: Any, n: int) -> NthValueFunction: ...
|
|
427
432
|
|
|
433
|
+
def raw(self, sql: str, *args) -> FunctionExpression: ...
|
|
434
|
+
|
|
435
|
+
def raw(self, sql: str, *args) -> "FunctionExpression":
|
|
436
|
+
"""Call an arbitrary SQL function by name.
|
|
437
|
+
|
|
438
|
+
Unlike col.raw() / FunctionExpression.raw() which insert the current
|
|
439
|
+
expression as the first argument, this standalone form takes the function
|
|
440
|
+
name and all arguments explicitly.
|
|
441
|
+
|
|
442
|
+
Args:
|
|
443
|
+
sql: SQL function name (e.g. "ts_rank", "to_tsvector")
|
|
444
|
+
*args: Arguments passed to the function. SQLAlchemy expressions
|
|
445
|
+
(ColumnElement, FunctionExpression) are used as-is; plain
|
|
446
|
+
Python values are wrapped with literal().
|
|
447
|
+
|
|
448
|
+
Examples:
|
|
449
|
+
func.raw("ts_rank", DocumentIndexes.content_vector, query_vec)
|
|
450
|
+
# → ts_rank(document_indexes.content_vector, <query_vec>)
|
|
451
|
+
|
|
452
|
+
func.raw("to_tsvector", "'simple'::regconfig", "some text")
|
|
453
|
+
# → to_tsvector('simple'::regconfig, 'some text')
|
|
454
|
+
"""
|
|
455
|
+
from sqlalchemy import literal
|
|
456
|
+
|
|
457
|
+
def _to_sql_arg(arg):
|
|
458
|
+
if isinstance(arg, (ColumnElement, FunctionExpression)):
|
|
459
|
+
return arg
|
|
460
|
+
return literal(arg)
|
|
461
|
+
|
|
462
|
+
sa_func = getattr(_sa_func, sql)
|
|
463
|
+
return FunctionExpression(sa_func(*[_to_sql_arg(a) for a in args]))
|
|
464
|
+
|
|
428
465
|
def __getattr__(self, name: str) -> Any:
|
|
429
466
|
"""Delegate to SQLAlchemy func for all other functions."""
|
|
430
467
|
return getattr(_sa_func, name)
|
|
@@ -50,6 +50,12 @@ class ComparatorMixin:
|
|
|
50
50
|
|
|
51
51
|
def raw(self, sql: str, *args, **kwargs) -> FunctionExpression:
|
|
52
52
|
from sqlalchemy import literal
|
|
53
|
+
from sqlalchemy.sql.elements import ColumnElement
|
|
54
|
+
|
|
55
|
+
def _to_sql_arg(arg):
|
|
56
|
+
if isinstance(arg, (ColumnElement, FunctionExpression)):
|
|
57
|
+
return arg
|
|
58
|
+
return literal(arg)
|
|
53
59
|
|
|
54
60
|
if ... in args:
|
|
55
61
|
all_args = []
|
|
@@ -57,9 +63,9 @@ class ComparatorMixin:
|
|
|
57
63
|
if arg is ...:
|
|
58
64
|
all_args.append(self)
|
|
59
65
|
else:
|
|
60
|
-
all_args.append(
|
|
66
|
+
all_args.append(_to_sql_arg(arg))
|
|
61
67
|
else:
|
|
62
|
-
all_args = [self] + [
|
|
68
|
+
all_args = [self] + [_to_sql_arg(arg) for arg in args]
|
|
63
69
|
raw_func = getattr(func, sql)
|
|
64
70
|
return FunctionExpression(raw_func(*all_args, **kwargs))
|
|
65
71
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlobjects
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Django-style async ORM library based on SQLAlchemy with chainable queries, Q objects, and relationship loading
|
|
5
5
|
Author-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
|
|
6
6
|
Maintainer-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|