execsql2 2.16.6__py3-none-any.whl → 2.16.8__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/script/executor.py +15 -1
- execsql/script/parser.py +40 -20
- {execsql2-2.16.6.dist-info → execsql2-2.16.8.dist-info}/METADATA +1 -1
- {execsql2-2.16.6.dist-info → execsql2-2.16.8.dist-info}/RECORD +23 -23
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/README.md +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/config_settings.sqlite +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/example_config_prompt.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/execsql.conf +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/make_config_db.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/md_compare.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/md_glossary.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/md_upsert.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/pg_compare.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/pg_glossary.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/pg_upsert.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/script_template.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/ss_compare.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/ss_glossary.sql +0 -0
- {execsql2-2.16.6.data → execsql2-2.16.8.data}/data/execsql2_extras/ss_upsert.sql +0 -0
- {execsql2-2.16.6.dist-info → execsql2-2.16.8.dist-info}/WHEEL +0 -0
- {execsql2-2.16.6.dist-info → execsql2-2.16.8.dist-info}/entry_points.txt +0 -0
- {execsql2-2.16.6.dist-info → execsql2-2.16.8.dist-info}/licenses/LICENSE.txt +0 -0
- {execsql2-2.16.6.dist-info → execsql2-2.16.8.dist-info}/licenses/NOTICE +0 -0
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
|
|
execsql/script/parser.py
CHANGED
|
@@ -163,6 +163,7 @@ def _parse_lines(lines: Iterable[str], source_name: str) -> Script:
|
|
|
163
163
|
in_sql_block = False # inside BEGIN SQL ... END SQL
|
|
164
164
|
sql_accum = "" # multi-line SQL accumulator
|
|
165
165
|
sql_start_line = 0
|
|
166
|
+
sql_accum_at_block_comment = False # was sql_accum non-empty when /* started?
|
|
166
167
|
|
|
167
168
|
def _current_body() -> list[Node]:
|
|
168
169
|
"""Return the body list that new nodes should be appended to."""
|
|
@@ -217,14 +218,21 @@ def _parse_lines(lines: Iterable[str], source_name: str) -> Script:
|
|
|
217
218
|
block_comment_lines.append(line)
|
|
218
219
|
if len(line) > 1 and line.rstrip().endswith("*/"):
|
|
219
220
|
in_block_comment = False
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
221
|
+
comment_text = "\n".join(block_comment_lines)
|
|
222
|
+
if sql_accum_at_block_comment:
|
|
223
|
+
# Block comment started inside a SQL statement — fold it
|
|
224
|
+
# back into sql_accum so the statement isn't split.
|
|
225
|
+
sql_accum += "\n" + comment_text
|
|
226
|
+
else:
|
|
227
|
+
_flush_sql(file_lineno)
|
|
228
|
+
_current_body().append(
|
|
229
|
+
Comment(
|
|
230
|
+
span=SourceSpan(source_name, block_comment_start, file_lineno),
|
|
231
|
+
text=comment_text,
|
|
232
|
+
),
|
|
233
|
+
)
|
|
227
234
|
block_comment_lines = []
|
|
235
|
+
sql_accum_at_block_comment = False
|
|
228
236
|
continue
|
|
229
237
|
|
|
230
238
|
# --- Single-line comment classification ---
|
|
@@ -232,12 +240,17 @@ def _parse_lines(lines: Iterable[str], source_name: str) -> Script:
|
|
|
232
240
|
comment_match = _COMMENT_LINE_RX.match(line)
|
|
233
241
|
|
|
234
242
|
if comment_match and not metacommand_match and not in_sql_block:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
243
|
+
if sql_accum:
|
|
244
|
+
# Inside a multi-line SQL statement — keep the comment as part
|
|
245
|
+
# of the SQL text so that commented-out columns, WHERE clauses,
|
|
246
|
+
# etc. don't split the statement.
|
|
247
|
+
sql_accum += "\n" + line.rstrip()
|
|
248
|
+
else:
|
|
249
|
+
# Standalone comment (not inside a SQL statement) — accumulate
|
|
250
|
+
# consecutive -- lines into a single Comment node.
|
|
251
|
+
if not line_comment_lines:
|
|
252
|
+
line_comment_start = file_lineno
|
|
253
|
+
line_comment_lines.append(line.rstrip())
|
|
241
254
|
continue
|
|
242
255
|
|
|
243
256
|
# Non-comment line — flush any accumulated -- comment group before proceeding.
|
|
@@ -248,17 +261,24 @@ def _parse_lines(lines: Iterable[str], source_name: str) -> Script:
|
|
|
248
261
|
if len(stripped) > 1 and stripped.startswith("/*"):
|
|
249
262
|
block_comment_start = file_lineno
|
|
250
263
|
block_comment_lines = [line]
|
|
264
|
+
# Remember whether we were inside a SQL statement when the block
|
|
265
|
+
# comment started, so we can fold it back on close.
|
|
266
|
+
sql_accum_at_block_comment = bool(sql_accum)
|
|
251
267
|
in_block_comment = True
|
|
252
268
|
if stripped.endswith("*/"):
|
|
253
269
|
in_block_comment = False
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
270
|
+
if sql_accum_at_block_comment:
|
|
271
|
+
sql_accum += "\n" + line.rstrip()
|
|
272
|
+
else:
|
|
273
|
+
_flush_sql(file_lineno)
|
|
274
|
+
_current_body().append(
|
|
275
|
+
Comment(
|
|
276
|
+
span=SourceSpan(source_name, file_lineno),
|
|
277
|
+
text=line,
|
|
278
|
+
),
|
|
279
|
+
)
|
|
261
280
|
block_comment_lines = []
|
|
281
|
+
sql_accum_at_block_comment = False
|
|
262
282
|
continue
|
|
263
283
|
|
|
264
284
|
# --- Metacommand handling ---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: execsql2
|
|
3
|
-
Version: 2.16.
|
|
3
|
+
Version: 2.16.8
|
|
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
|
|
@@ -84,8 +84,8 @@ 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=
|
|
88
|
-
execsql/script/parser.py,sha256=
|
|
87
|
+
execsql/script/executor.py,sha256=SeY7Xiky1hBrNG8Z-MV6uhLhayvVFByUH02N5YZbyHA,36546
|
|
88
|
+
execsql/script/parser.py,sha256=reqKs_JP1H_m43B2d4MeZH4zHY-pnGUGCwDX0IBdJwA,26109
|
|
89
89
|
execsql/script/variables.py,sha256=ZSBGQUsoii6w3dLDVY9xxoPIV6wY0sAV_BNIQ6pgQAE,14328
|
|
90
90
|
execsql/utils/__init__.py,sha256=0uR6JwVJQRX3vceByNBduCAf5dd5assKjeqJUWvpZoA,278
|
|
91
91
|
execsql/utils/auth.py,sha256=onXzNkNZQZxGC5w7eey06sjvAIAX_Lf9g7nUJtcsel0,7009
|
|
@@ -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.8.data/data/execsql2_extras/README.md,sha256=sxwVyU0ZahCfANv56LahkyuM505kFjrMhe-1SvWE69E,4845
|
|
103
|
+
execsql2-2.16.8.data/data/execsql2_extras/config_settings.sqlite,sha256=aY5cxR7Q7J6zJ4bC9lu5mHUrhy211Cq3MNKPQVCt02E,20480
|
|
104
|
+
execsql2-2.16.8.data/data/execsql2_extras/example_config_prompt.sql,sha256=SY3Jxn1qcVm4kPW9xmmTfknHfvURXmeEYTbRjYrjGSw,7487
|
|
105
|
+
execsql2-2.16.8.data/data/execsql2_extras/execsql.conf,sha256=_45iJ-KWZnB8uMW_gEg067MM5pmGJ-dVl7VbAZMunAE,9530
|
|
106
|
+
execsql2-2.16.8.data/data/execsql2_extras/make_config_db.sql,sha256=WwyC6dK-Eh5CAVppiBCDHqiI1_wEI9U95Ytpr4lsZkg,8726
|
|
107
|
+
execsql2-2.16.8.data/data/execsql2_extras/md_compare.sql,sha256=B8Wd7LZ0vnMY2qvA139JIEBkPObgRH2i5xj6PejTQt8,24092
|
|
108
|
+
execsql2-2.16.8.data/data/execsql2_extras/md_glossary.sql,sha256=DJRHcU5NbFpxTTX-IwH3yRlsboj1q6BBGrUAHKn4Cuo,10796
|
|
109
|
+
execsql2-2.16.8.data/data/execsql2_extras/md_upsert.sql,sha256=v_7GbWh_N1mBTmw3gvTrkagOVp2q0KmXvM8hE-DlFxY,112524
|
|
110
|
+
execsql2-2.16.8.data/data/execsql2_extras/pg_compare.sql,sha256=9dWa8hnfy5dVJI-z2iGpd9JzQmI4j2ziMlEdpnr66ro,24352
|
|
111
|
+
execsql2-2.16.8.data/data/execsql2_extras/pg_glossary.sql,sha256=pKjIIDsROAgJq2H-1qNEcRMAWManivcZ_AEVHzUUlic,9908
|
|
112
|
+
execsql2-2.16.8.data/data/execsql2_extras/pg_upsert.sql,sha256=k7AFiGTLBy3nf-qO5QIaZrEYTAKvdxxU3JDLx9jqkzs,108315
|
|
113
|
+
execsql2-2.16.8.data/data/execsql2_extras/script_template.sql,sha256=1Estacb_vm1FgK41k_G9nuduP1yiA-fQ1Kn4Z4mv5Ao,11153
|
|
114
|
+
execsql2-2.16.8.data/data/execsql2_extras/ss_compare.sql,sha256=TsVxWm3cEpR5-EiMYXNhtaY0arSNeKZhsJdHdLA7xeI,24833
|
|
115
|
+
execsql2-2.16.8.data/data/execsql2_extras/ss_glossary.sql,sha256=cLM7nN8JOIu9ZVP9oY9qdSK3hrnWJiDcX6nZmQQbQWI,13065
|
|
116
|
+
execsql2-2.16.8.data/data/execsql2_extras/ss_upsert.sql,sha256=BCqmBykXBF-BpCgOFeG1qhf2XfScKsxPD17wd1hYfHw,120647
|
|
117
|
+
execsql2-2.16.8.dist-info/METADATA,sha256=Bqs0Wsv_KmnbyPSAsJbYHnlK-PAn7TX3LZUXgWHHwws,20920
|
|
118
|
+
execsql2-2.16.8.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
119
|
+
execsql2-2.16.8.dist-info/entry_points.txt,sha256=sUOxkM-dN1eBGGpSpDLsAaE0yNXYQKWZAfxPOlMkQyk,90
|
|
120
|
+
execsql2-2.16.8.dist-info/licenses/LICENSE.txt,sha256=LBdhuxejF8_bLCHZ2kWfmDXpDGUu914Gbd6_3JjCRe0,676
|
|
121
|
+
execsql2-2.16.8.dist-info/licenses/NOTICE,sha256=sqVrM73Ys9zfvWC_P797lHfTnoPW_ETeBSrUTFaob0A,339
|
|
122
|
+
execsql2-2.16.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{execsql2-2.16.6.data → execsql2-2.16.8.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
|