sqlspec 0.24.0__py3-none-any.whl → 0.24.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/_sql.py +10 -8
- {sqlspec-0.24.0.dist-info → sqlspec-0.24.1.dist-info}/METADATA +1 -1
- {sqlspec-0.24.0.dist-info → sqlspec-0.24.1.dist-info}/RECORD +7 -7
- {sqlspec-0.24.0.dist-info → sqlspec-0.24.1.dist-info}/WHEEL +0 -0
- {sqlspec-0.24.0.dist-info → sqlspec-0.24.1.dist-info}/entry_points.txt +0 -0
- {sqlspec-0.24.0.dist-info → sqlspec-0.24.1.dist-info}/licenses/LICENSE +0 -0
- {sqlspec-0.24.0.dist-info → sqlspec-0.24.1.dist-info}/licenses/NOTICE +0 -0
sqlspec/_sql.py
CHANGED
|
@@ -137,21 +137,18 @@ class SQLFactory:
|
|
|
137
137
|
self.dialect = dialect
|
|
138
138
|
|
|
139
139
|
def __call__(self, statement: str, dialect: DialectType = None) -> "Any":
|
|
140
|
-
"""Create a SelectBuilder from a SQL string,
|
|
140
|
+
"""Create a SelectBuilder from a SQL string, or SQL object for DML with RETURNING.
|
|
141
141
|
|
|
142
142
|
Args:
|
|
143
143
|
statement: The SQL statement string.
|
|
144
|
-
parameters: Optional parameters for the query.
|
|
145
|
-
*filters: Optional filters.
|
|
146
|
-
config: Optional config.
|
|
147
144
|
dialect: Optional SQL dialect.
|
|
148
|
-
**kwargs: Additional parameters.
|
|
149
145
|
|
|
150
146
|
Returns:
|
|
151
|
-
SelectBuilder instance
|
|
147
|
+
SelectBuilder instance for SELECT/WITH statements,
|
|
148
|
+
SQL object for DML statements with RETURNING clause.
|
|
152
149
|
|
|
153
150
|
Raises:
|
|
154
|
-
SQLBuilderError: If the SQL is not a SELECT/CTE statement.
|
|
151
|
+
SQLBuilderError: If the SQL is not a SELECT/CTE/DML+RETURNING statement.
|
|
155
152
|
"""
|
|
156
153
|
|
|
157
154
|
try:
|
|
@@ -175,8 +172,13 @@ class SQLFactory:
|
|
|
175
172
|
builder = Select(dialect=dialect or self.dialect)
|
|
176
173
|
builder._expression = parsed_expr
|
|
177
174
|
return builder
|
|
175
|
+
|
|
176
|
+
if actual_type_str in {"INSERT", "UPDATE", "DELETE"} and parsed_expr.args.get("returning") is not None:
|
|
177
|
+
return SQL(statement)
|
|
178
|
+
|
|
178
179
|
msg = (
|
|
179
|
-
f"sql(...) only supports SELECT statements
|
|
180
|
+
f"sql(...) only supports SELECT statements or DML statements with RETURNING clause. "
|
|
181
|
+
f"Detected type: {actual_type_str}. "
|
|
180
182
|
f"Use sql.{actual_type_str.lower()}() instead."
|
|
181
183
|
)
|
|
182
184
|
raise SQLBuilderError(msg)
|
|
@@ -2,7 +2,7 @@ sqlspec/__init__.py,sha256=JkL9cp1h19tz1rCl-3WAep6kbZs8JLxNlb1SrQl8PWc,2114
|
|
|
2
2
|
sqlspec/__main__.py,sha256=lXBKZMOXA1uY735Rnsb-GS7aXy0nt22tYmd2X9FcxrY,253
|
|
3
3
|
sqlspec/__metadata__.py,sha256=IUw6MCTy1oeUJ1jAVYbuJLkOWbiAWorZ5W-E-SAD9N4,395
|
|
4
4
|
sqlspec/_serialization.py,sha256=6U5-smk2h2yl0i6am2prtOLJTdu4NJQdcLlSfSUMaUQ,2590
|
|
5
|
-
sqlspec/_sql.py,sha256=
|
|
5
|
+
sqlspec/_sql.py,sha256=bU-8kTUJ9qP2xtm28fcVKAWA7zPZjjgYq3DvNQPs63Q,46354
|
|
6
6
|
sqlspec/_typing.py,sha256=jv-7QHGLrJLfnP86bR-Xcmj3PDoddNZEKDz_vYRBiAU,22684
|
|
7
7
|
sqlspec/base.py,sha256=koDh1AecwCAkntSqSda6J_cpMOLonXiV6hh3GCCXf_s,25459
|
|
8
8
|
sqlspec/cli.py,sha256=Fe5Wbnrb_fkE9qm4gbBEXx3d0Q7VR-S-1t76ouAx2mg,20120
|
|
@@ -131,9 +131,9 @@ sqlspec/utils/singleton.py,sha256=-j-s6LS0pP_wTEUYIyK2wSdoeIE_tn7O7B-j7_aODRQ,12
|
|
|
131
131
|
sqlspec/utils/sync_tools.py,sha256=ONdhmx1Dq0_c6ReRaTlXzz6dVmAwz6CybCvsTUAVu1g,8768
|
|
132
132
|
sqlspec/utils/text.py,sha256=ZqaXCVuUbdj_110pdTYjmAxfV3ZtR7J6EixuNazQLFY,3333
|
|
133
133
|
sqlspec/utils/type_guards.py,sha256=0KCosuWZXWExUDJTHPSAP0KxXOokX3eraTjTxURUAJ0,33762
|
|
134
|
-
sqlspec-0.24.
|
|
135
|
-
sqlspec-0.24.
|
|
136
|
-
sqlspec-0.24.
|
|
137
|
-
sqlspec-0.24.
|
|
138
|
-
sqlspec-0.24.
|
|
139
|
-
sqlspec-0.24.
|
|
134
|
+
sqlspec-0.24.1.dist-info/METADATA,sha256=CYcuJNIdsaFqPv4k3TxUOY1WU2bmCa7MARWFGh1ptx0,23548
|
|
135
|
+
sqlspec-0.24.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
136
|
+
sqlspec-0.24.1.dist-info/entry_points.txt,sha256=G-ZqY1Nuuw3Iys7nXw23f6ILenk_Lt47VdK2mhJCWHg,53
|
|
137
|
+
sqlspec-0.24.1.dist-info/licenses/LICENSE,sha256=MdujfZ6l5HuLz4mElxlu049itenOR3gnhN1_Nd3nVcM,1078
|
|
138
|
+
sqlspec-0.24.1.dist-info/licenses/NOTICE,sha256=Lyir8ozXWov7CyYS4huVaOCNrtgL17P-bNV-5daLntQ,1634
|
|
139
|
+
sqlspec-0.24.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|