execsql2 2.16.5__py3-none-any.whl → 2.16.7__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.
- execsql/format.py +16 -2
- execsql/script/executor.py +15 -1
- {execsql2-2.16.5.dist-info → execsql2-2.16.7.dist-info}/METADATA +1 -1
- {execsql2-2.16.5.dist-info → execsql2-2.16.7.dist-info}/RECORD +23 -23
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/README.md +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/config_settings.sqlite +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/example_config_prompt.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/execsql.conf +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/make_config_db.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/md_compare.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/md_glossary.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/md_upsert.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/pg_compare.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/pg_glossary.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/pg_upsert.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/script_template.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/ss_compare.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/ss_glossary.sql +0 -0
- {execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/ss_upsert.sql +0 -0
- {execsql2-2.16.5.dist-info → execsql2-2.16.7.dist-info}/WHEEL +0 -0
- {execsql2-2.16.5.dist-info → execsql2-2.16.7.dist-info}/entry_points.txt +0 -0
- {execsql2-2.16.5.dist-info → execsql2-2.16.7.dist-info}/licenses/LICENSE.txt +0 -0
- {execsql2-2.16.5.dist-info → execsql2-2.16.7.dist-info}/licenses/NOTICE +0 -0
execsql/format.py
CHANGED
|
@@ -242,16 +242,27 @@ def format_file(source: str, indent: int = 4, use_sql: bool = True) -> str:
|
|
|
242
242
|
sql_acc: list[str] = []
|
|
243
243
|
output: list[str] = []
|
|
244
244
|
|
|
245
|
+
in_dollar_quote = False
|
|
246
|
+
|
|
245
247
|
def flush_sql() -> None:
|
|
248
|
+
nonlocal in_dollar_quote
|
|
246
249
|
if sql_acc:
|
|
247
|
-
|
|
250
|
+
# If any line in the accumulated block is inside a $$-delimited
|
|
251
|
+
# region, skip sqlglot formatting entirely. PL/pgSQL function
|
|
252
|
+
# bodies contain IF/END IF, LOOP, RETURN, etc. that sqlglot does
|
|
253
|
+
# not understand and will corrupt (e.g., rewriting to COMMIT).
|
|
254
|
+
safe_for_sqlglot = use_sql and not in_dollar_quote
|
|
255
|
+
output.extend(format_sql_block(sql_acc, depth, indent, safe_for_sqlglot))
|
|
248
256
|
sql_acc.clear()
|
|
249
257
|
|
|
250
258
|
for raw_line in source.expandtabs(4).splitlines():
|
|
251
259
|
m = METACOMMAND_RE.match(raw_line)
|
|
252
260
|
|
|
253
261
|
if not raw_line.strip():
|
|
254
|
-
|
|
262
|
+
if not in_dollar_quote:
|
|
263
|
+
flush_sql()
|
|
264
|
+
else:
|
|
265
|
+
sql_acc.append(raw_line)
|
|
255
266
|
output.append("")
|
|
256
267
|
|
|
257
268
|
elif m:
|
|
@@ -279,6 +290,9 @@ def format_file(source: str, indent: int = 4, use_sql: bool = True) -> str:
|
|
|
279
290
|
output.append(format_metacommand(payload, depth, indent))
|
|
280
291
|
|
|
281
292
|
else:
|
|
293
|
+
# Track $$ boundaries to prevent sqlglot from mangling PL/pgSQL
|
|
294
|
+
if "$$" in raw_line and raw_line.count("$$") % 2 == 1:
|
|
295
|
+
in_dollar_quote = not in_dollar_quote
|
|
282
296
|
sql_acc.append(raw_line)
|
|
283
297
|
|
|
284
298
|
flush_sql()
|
execsql/script/executor.py
CHANGED
|
@@ -139,13 +139,24 @@ def _eval_condition(
|
|
|
139
139
|
condition: str,
|
|
140
140
|
modifiers: list[ConditionModifier] | None = None,
|
|
141
141
|
) -> bool:
|
|
142
|
-
"""Evaluate a condition string with optional ANDIF/ORIF modifiers.
|
|
142
|
+
"""Evaluate a condition string with optional ANDIF/ORIF modifiers.
|
|
143
|
+
|
|
144
|
+
Short-circuits ANDIF (stops on first False) and ORIF (stops on first True)
|
|
145
|
+
so that patterns like ``IF (sub_defined(x)) ANDIF (not sub_empty(x))``
|
|
146
|
+
don't evaluate ``sub_empty`` when ``x`` is undefined.
|
|
147
|
+
"""
|
|
143
148
|
effective_locals = _stack_localvars(ctx)
|
|
144
149
|
expanded = substitute_vars(condition, effective_locals, ctx=ctx)
|
|
145
150
|
result = xcmd_test(expanded)
|
|
146
151
|
|
|
147
152
|
if modifiers:
|
|
148
153
|
for mod in modifiers:
|
|
154
|
+
# Short-circuit: AND with False can't become True,
|
|
155
|
+
# OR with True can't become False.
|
|
156
|
+
if mod.kind == "AND" and not result:
|
|
157
|
+
continue
|
|
158
|
+
if mod.kind == "OR" and result:
|
|
159
|
+
continue
|
|
149
160
|
mod_expanded = substitute_vars(mod.condition, effective_locals, ctx=ctx)
|
|
150
161
|
mod_result = xcmd_test(mod_expanded)
|
|
151
162
|
if mod.kind == "AND":
|
|
@@ -353,9 +364,11 @@ def _execute_node(
|
|
|
353
364
|
_exec_metacommand(ctx, command, node.span.file, node.span.start_line, localvars)
|
|
354
365
|
|
|
355
366
|
elif isinstance(node, IfBlock):
|
|
367
|
+
ctx.last_command = _FakeScriptCmd(node)
|
|
356
368
|
_execute_if(ctx, node, localvars, in_loop=in_loop)
|
|
357
369
|
|
|
358
370
|
elif isinstance(node, LoopBlock):
|
|
371
|
+
ctx.last_command = _FakeScriptCmd(node)
|
|
359
372
|
_execute_loop(ctx, node, localvars)
|
|
360
373
|
|
|
361
374
|
elif isinstance(node, BatchBlock):
|
|
@@ -368,6 +381,7 @@ def _execute_node(
|
|
|
368
381
|
_execute_sql_block(ctx, node, localvars, in_loop=in_loop)
|
|
369
382
|
|
|
370
383
|
elif isinstance(node, IncludeDirective):
|
|
384
|
+
ctx.last_command = _FakeScriptCmd(node)
|
|
371
385
|
_execute_include(ctx, node, localvars)
|
|
372
386
|
|
|
373
387
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: execsql2
|
|
3
|
-
Version: 2.16.
|
|
3
|
+
Version: 2.16.7
|
|
4
4
|
Summary: Runs a SQL script against a PostgreSQL, SQLite, MariaDB/MySQL, DuckDB, Firebird, MS-Access, MS-SQL-Server, or Oracle database, or an ODBC DSN. Provides metacommands to import and export data, copy data between databases, conditionally execute SQL and metacommands, and dynamically alter SQL and metacommands with substitution variables.
|
|
5
5
|
Project-URL: Homepage, https://execsql2.readthedocs.io
|
|
6
6
|
Project-URL: Repository, https://github.com/geocoug/execsql
|
|
@@ -3,7 +3,7 @@ execsql/__main__.py,sha256=HdbK-SAhyUmfB6xINY5AzxdMSxGzWSGEG_2dv42Jn64,315
|
|
|
3
3
|
execsql/api.py,sha256=0D2Rl329fvDXERNrJBUzoWEt_VxqCHwRgaGzrq04rVs,19709
|
|
4
4
|
execsql/config.py,sha256=6icjr8PKenUGfFF6lciSclvejjDzY8GTW1OZ1-IZt-Y,29480
|
|
5
5
|
execsql/exceptions.py,sha256=j8hykBiof9H3Za9hwLIbDcVB2Xn65ODXXplp1jkvdgM,8453
|
|
6
|
-
execsql/format.py,sha256
|
|
6
|
+
execsql/format.py,sha256=IsCM5T1iBC54CkBJNfO55ycJk-aKRZJjtnwXk0jepTA,12723
|
|
7
7
|
execsql/models.py,sha256=kCTUQg9-vReM6WNFfB_ZrEppuOW5u1uMBQThSkfPC0o,13264
|
|
8
8
|
execsql/parser.py,sha256=P3ea8k7T_XLMrbhpFNZXwytdShrY302MKnhosqza1lo,15493
|
|
9
9
|
execsql/plugins.py,sha256=2voLwT6eFap6BCBoZYndNNC_bMEJO1f_aP6xQTVXwYI,12815
|
|
@@ -84,7 +84,7 @@ execsql/script/__init__.py,sha256=3WaBklMVIWjtCsYQ-BVo9UAVEIATOgeGsuyv21YKnxo,39
|
|
|
84
84
|
execsql/script/ast.py,sha256=yFw9ZvLLDNNSmSgy7cwK2fXLatpp2CKYAAyOneJoKVc,18836
|
|
85
85
|
execsql/script/control.py,sha256=s-1eZdGARM6H1FwZ6VDdO_f50j7bvvRtTHesfUm9tbc,6144
|
|
86
86
|
execsql/script/engine.py,sha256=EhuVBniOrFkzAW4I3NIZLt3INHTZJvlYoF7B99rZBLI,29391
|
|
87
|
-
execsql/script/executor.py,sha256=
|
|
87
|
+
execsql/script/executor.py,sha256=SeY7Xiky1hBrNG8Z-MV6uhLhayvVFByUH02N5YZbyHA,36546
|
|
88
88
|
execsql/script/parser.py,sha256=nAyLaDP-nL6C-chvlaSu0Oqh8ACcCCZjFacv0Fhyp58,24983
|
|
89
89
|
execsql/script/variables.py,sha256=ZSBGQUsoii6w3dLDVY9xxoPIV6wY0sAV_BNIQ6pgQAE,14328
|
|
90
90
|
execsql/utils/__init__.py,sha256=0uR6JwVJQRX3vceByNBduCAf5dd5assKjeqJUWvpZoA,278
|
|
@@ -99,24 +99,24 @@ execsql/utils/numeric.py,sha256=xh02ANSRk3nUpQ-rtm66ILoMqoi7HtzCoRMIOT9U8QI,1570
|
|
|
99
99
|
execsql/utils/regex.py,sha256=diEzTZqU_HHwVMadPAvN1Vgzhl7I03eVaEFGCXyGGL8,3770
|
|
100
100
|
execsql/utils/strings.py,sha256=5Dvzrk-9SIw2lpxXZQkiJbNyo1sy7iXXAtSULlZ0KG8,8488
|
|
101
101
|
execsql/utils/timer.py,sha256=eDYf5VzCNFk7oo90InJucUm3XcBdhYMogjZMqeg9xzc,1899
|
|
102
|
-
execsql2-2.16.
|
|
103
|
-
execsql2-2.16.
|
|
104
|
-
execsql2-2.16.
|
|
105
|
-
execsql2-2.16.
|
|
106
|
-
execsql2-2.16.
|
|
107
|
-
execsql2-2.16.
|
|
108
|
-
execsql2-2.16.
|
|
109
|
-
execsql2-2.16.
|
|
110
|
-
execsql2-2.16.
|
|
111
|
-
execsql2-2.16.
|
|
112
|
-
execsql2-2.16.
|
|
113
|
-
execsql2-2.16.
|
|
114
|
-
execsql2-2.16.
|
|
115
|
-
execsql2-2.16.
|
|
116
|
-
execsql2-2.16.
|
|
117
|
-
execsql2-2.16.
|
|
118
|
-
execsql2-2.16.
|
|
119
|
-
execsql2-2.16.
|
|
120
|
-
execsql2-2.16.
|
|
121
|
-
execsql2-2.16.
|
|
122
|
-
execsql2-2.16.
|
|
102
|
+
execsql2-2.16.7.data/data/execsql2_extras/README.md,sha256=sxwVyU0ZahCfANv56LahkyuM505kFjrMhe-1SvWE69E,4845
|
|
103
|
+
execsql2-2.16.7.data/data/execsql2_extras/config_settings.sqlite,sha256=aY5cxR7Q7J6zJ4bC9lu5mHUrhy211Cq3MNKPQVCt02E,20480
|
|
104
|
+
execsql2-2.16.7.data/data/execsql2_extras/example_config_prompt.sql,sha256=SY3Jxn1qcVm4kPW9xmmTfknHfvURXmeEYTbRjYrjGSw,7487
|
|
105
|
+
execsql2-2.16.7.data/data/execsql2_extras/execsql.conf,sha256=_45iJ-KWZnB8uMW_gEg067MM5pmGJ-dVl7VbAZMunAE,9530
|
|
106
|
+
execsql2-2.16.7.data/data/execsql2_extras/make_config_db.sql,sha256=WwyC6dK-Eh5CAVppiBCDHqiI1_wEI9U95Ytpr4lsZkg,8726
|
|
107
|
+
execsql2-2.16.7.data/data/execsql2_extras/md_compare.sql,sha256=B8Wd7LZ0vnMY2qvA139JIEBkPObgRH2i5xj6PejTQt8,24092
|
|
108
|
+
execsql2-2.16.7.data/data/execsql2_extras/md_glossary.sql,sha256=DJRHcU5NbFpxTTX-IwH3yRlsboj1q6BBGrUAHKn4Cuo,10796
|
|
109
|
+
execsql2-2.16.7.data/data/execsql2_extras/md_upsert.sql,sha256=v_7GbWh_N1mBTmw3gvTrkagOVp2q0KmXvM8hE-DlFxY,112524
|
|
110
|
+
execsql2-2.16.7.data/data/execsql2_extras/pg_compare.sql,sha256=9dWa8hnfy5dVJI-z2iGpd9JzQmI4j2ziMlEdpnr66ro,24352
|
|
111
|
+
execsql2-2.16.7.data/data/execsql2_extras/pg_glossary.sql,sha256=pKjIIDsROAgJq2H-1qNEcRMAWManivcZ_AEVHzUUlic,9908
|
|
112
|
+
execsql2-2.16.7.data/data/execsql2_extras/pg_upsert.sql,sha256=k7AFiGTLBy3nf-qO5QIaZrEYTAKvdxxU3JDLx9jqkzs,108315
|
|
113
|
+
execsql2-2.16.7.data/data/execsql2_extras/script_template.sql,sha256=1Estacb_vm1FgK41k_G9nuduP1yiA-fQ1Kn4Z4mv5Ao,11153
|
|
114
|
+
execsql2-2.16.7.data/data/execsql2_extras/ss_compare.sql,sha256=TsVxWm3cEpR5-EiMYXNhtaY0arSNeKZhsJdHdLA7xeI,24833
|
|
115
|
+
execsql2-2.16.7.data/data/execsql2_extras/ss_glossary.sql,sha256=cLM7nN8JOIu9ZVP9oY9qdSK3hrnWJiDcX6nZmQQbQWI,13065
|
|
116
|
+
execsql2-2.16.7.data/data/execsql2_extras/ss_upsert.sql,sha256=BCqmBykXBF-BpCgOFeG1qhf2XfScKsxPD17wd1hYfHw,120647
|
|
117
|
+
execsql2-2.16.7.dist-info/METADATA,sha256=oHrJqm7vLZkhceyfwOT40zUVOIZs_kSp_0F2UGXgblw,20920
|
|
118
|
+
execsql2-2.16.7.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
119
|
+
execsql2-2.16.7.dist-info/entry_points.txt,sha256=sUOxkM-dN1eBGGpSpDLsAaE0yNXYQKWZAfxPOlMkQyk,90
|
|
120
|
+
execsql2-2.16.7.dist-info/licenses/LICENSE.txt,sha256=LBdhuxejF8_bLCHZ2kWfmDXpDGUu914Gbd6_3JjCRe0,676
|
|
121
|
+
execsql2-2.16.7.dist-info/licenses/NOTICE,sha256=sqVrM73Ys9zfvWC_P797lHfTnoPW_ETeBSrUTFaob0A,339
|
|
122
|
+
execsql2-2.16.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{execsql2-2.16.5.data → execsql2-2.16.7.data}/data/execsql2_extras/example_config_prompt.sql
RENAMED
|
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
|