mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 08:02:38 +00:00
fix(datatables): carry the role annotation into the row_to_json retry
The retry rebuilds its SQL from `pruneComments(code)`, so the leading comment block never reached the second attempt — and with it the `-- role <name>` line that decides which login the query runs as. The retry connected as the data table's default role instead, so a query the first attempt was denied could succeed on the second, reported as "recovered with the row_to_json fix". Carry the leading comment block over. The retry itself is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BjfMkJyKzodxkobqGZ6Lqb
This commit is contained in:
co-authored by
Claude Opus 5
parent
da3babccc7
commit
fce20faeae
@@ -103,14 +103,21 @@
|
||||
// We don't always put the fix by default for row ordering concerns
|
||||
let transformedCode = code
|
||||
if (doPostgresRowToJsonFix) {
|
||||
transformedCode = statements
|
||||
.map((statement) => {
|
||||
if (READ_OPS.some((op) => statement.trim().toUpperCase().startsWith(op))) {
|
||||
return `SELECT row_to_json(__t__) FROM (${statement}) __t__`
|
||||
}
|
||||
return statement
|
||||
})
|
||||
.join(';')
|
||||
// Rebuilt from the pruned statements, which drops the leading comment block — and
|
||||
// with it the `-- role <name>` annotation that decides which login the query runs
|
||||
// as. Carry it over, or the retry connects as the data table's default role and a
|
||||
// query the first attempt was denied succeeds on the second.
|
||||
const leadingAnnotations = code.match(/^(?:[^\S\n]*\n|[^\S\n]*--[^\n]*\n)*/)?.[0] ?? ''
|
||||
transformedCode =
|
||||
leadingAnnotations +
|
||||
statements
|
||||
.map((statement) => {
|
||||
if (READ_OPS.some((op) => statement.trim().toUpperCase().startsWith(op))) {
|
||||
return `SELECT row_to_json(__t__) FROM (${statement}) __t__`
|
||||
}
|
||||
return statement
|
||||
})
|
||||
.join(';')
|
||||
}
|
||||
const dbArg = getDatabaseArg(input)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user