mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-28 16:06:22 +00:00
fix: bind datatable() args as literals and read _FLOW_PATH on previews (#12638)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
90e938492a
commit
a8b2228753
@@ -2723,6 +2723,11 @@ def stream_result(stream) -> None:
|
||||
for text in stream:
|
||||
append_to_result_stream(text)
|
||||
|
||||
# Tells the executor that the args are bound values, to pass on as they are, so a value
|
||||
# that reads like `$var:u/alice/key` reaches the database as that text. A server that
|
||||
# predates the annotation ignores it.
|
||||
_LITERAL_ARGS_ANNOTATION = "-- literal_args\n"
|
||||
|
||||
# Interpolated into a `-- role <name>` line, so a value carrying a newline could append
|
||||
# statements of its own. Mirrors the server's own role-name rule.
|
||||
_ROLE_NAME_RE = re.compile(r"^[A-Za-z0-9_-]{1,63}$")
|
||||
@@ -2768,6 +2773,7 @@ class DataTableClient:
|
||||
# Must lead: the executor's annotation parser stops at the first non-comment line.
|
||||
if self.role is not None:
|
||||
sql = f"-- role {self.role}\n" + sql
|
||||
sql = _LITERAL_ARGS_ANNOTATION + sql
|
||||
return SqlQuery(
|
||||
sql,
|
||||
lambda sql: self.client.run_inline_script_preview(
|
||||
@@ -2806,7 +2812,7 @@ class DucklakeClient:
|
||||
args_dict[key] = value
|
||||
args_def += f"-- ${key} ({infer_sql_type(value)})\n"
|
||||
attach = f"ATTACH 'ducklake://{self.name}' AS dl;USE dl;\n"
|
||||
sql = args_def + attach + sql
|
||||
sql = _LITERAL_ARGS_ANNOTATION + args_def + attach + sql
|
||||
return SqlQuery(
|
||||
sql,
|
||||
lambda sql: self.client.run_inline_script_preview(
|
||||
|
||||
Reference in New Issue
Block a user