sqlakit 0.22.5__tar.gz → 0.22.7__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.
- {sqlakit-0.22.5 → sqlakit-0.22.7}/PKG-INFO +1 -1
- {sqlakit-0.22.5 → sqlakit-0.22.7}/pyproject.toml +1 -1
- {sqlakit-0.22.5 → sqlakit-0.22.7}/pyproject.toml.orig +1 -1
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_sql.py +21 -6
- {sqlakit-0.22.5 → sqlakit-0.22.7}/LICENSE +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/README.md +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/__init__.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_base.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_cli.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_db.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_discovery.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_linters.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_model.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_project.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_pycharm.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_query.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_recording.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_registry.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_render.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_routing.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_sql_formatter.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/_static.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/asyncio/__init__.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/asyncio/_db.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/asyncio/_registry.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/asyncio/orm.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/asyncio/sql.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/exceptions.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/orm.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/py.typed +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/pytest_plugin.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/sql.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/testing.py +0 -0
- {sqlakit-0.22.5 → sqlakit-0.22.7}/sqlakit/types.py +0 -0
|
@@ -328,12 +328,15 @@ class Context:
|
|
|
328
328
|
self.values: dict[str, Any] = dict(values)
|
|
329
329
|
self._bound = 0
|
|
330
330
|
|
|
331
|
-
|
|
332
|
-
|
|
331
|
+
@property
|
|
332
|
+
def no_order(self) -> str:
|
|
333
|
+
"""An `ORDER BY` term that orders by nothing, for a macro with nothing to sort by.
|
|
333
334
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
PostgreSQL and SQL Server refuse a bare `NULL` there, and take
|
|
336
|
+
`(SELECT NULL)`. Snowflake refuses a subquery there, and takes `NULL`,
|
|
337
|
+
as MySQL, SQLite and Oracle do. `0` would be a column's position.
|
|
338
|
+
"""
|
|
339
|
+
return "(SELECT NULL)" if self.dialect in ("postgresql", "mssql") else "NULL"
|
|
337
340
|
|
|
338
341
|
def __repr__(self) -> str:
|
|
339
342
|
return f"{type(self).__name__}({self.dialect!r})"
|
|
@@ -1954,6 +1957,16 @@ def unless_set(value: Param, expr: Sql, otherwise: Sql = Sql("TRUE")) -> str: #
|
|
|
1954
1957
|
return _grouped(str(otherwise if _is_set(value.value) else expr))
|
|
1955
1958
|
|
|
1956
1959
|
|
|
1960
|
+
@sql_macro(optional=True, lazy=True)
|
|
1961
|
+
def if_not_set(value: Param, expr: Sql, otherwise: Sql = Sql("TRUE")) -> str: # noqa: B008
|
|
1962
|
+
"""`expr` when the parameter holds no value: another name for `unless_set`.
|
|
1963
|
+
|
|
1964
|
+
It reads as the other way round from `if_set`:
|
|
1965
|
+
`AND tpl.if_not_set(:status, status <> 'archived')`.
|
|
1966
|
+
"""
|
|
1967
|
+
return _grouped(str(otherwise if _is_set(value.value) else expr))
|
|
1968
|
+
|
|
1969
|
+
|
|
1957
1970
|
@sql_macro(optional=True)
|
|
1958
1971
|
def array(ctx: Context, values: Param, type_name: Sql = Sql("")) -> str: # noqa: B008
|
|
1959
1972
|
"""Write a list as an array, one parameter per value.
|
|
@@ -2064,7 +2077,8 @@ def order_by(ctx: Context, sort: Param, column: Sql, *columns: Sql) -> str:
|
|
|
2064
2077
|
the nulls of every term whose sort string does not say, and MySQL, which
|
|
2065
2078
|
has no `NULLS LAST`, sorts by `IS NULL` first. Any other string is the sort
|
|
2066
2079
|
when the call passes none, `'name.asc'` above. With neither, the rows come
|
|
2067
|
-
in no order: `(SELECT NULL)
|
|
2080
|
+
in no order: `NULL`, or `(SELECT NULL)` on PostgreSQL and SQL Server, which
|
|
2081
|
+
refuse a bare `NULL`.
|
|
2068
2082
|
"""
|
|
2069
2083
|
written = [one.strip() for one in (column, *columns)]
|
|
2070
2084
|
options = [one.strip("'") for one in written if one.startswith("'")]
|
|
@@ -2564,6 +2578,7 @@ BUILTIN_MACROS: Mapping[str, Macro] = {
|
|
|
2564
2578
|
for macro in (
|
|
2565
2579
|
if_set,
|
|
2566
2580
|
unless_set,
|
|
2581
|
+
if_not_set,
|
|
2567
2582
|
order_by,
|
|
2568
2583
|
icontains,
|
|
2569
2584
|
icollate,
|
|
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
|