Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/runtime/edge-runtime/ext/trex/js/dbconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,10 @@ export class TrexConnection {
`${duckdbNativeSchemName}.COHORT`
);
}*/
const replacement = schemaName === "" ? "" : `${schemaName}.`;
// Use fully qualified 3-part name (catalog.schema.table) to avoid DuckDB
// "Ambiguous reference to catalog or schema" error when databaseCode equals schemaName
const databaseName = this.connection.getdatabase();
const replacement = schemaName === "" ? "" : `${databaseName}.${schemaName}.`;
Comment on lines +404 to +406
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change always rewrites $$SCHEMA$$.* references to a 3-part name (catalog.schema.table), but the comment/PR context suggests it’s only required when the catalog name and schema name collide (e.g., databaseCode === schemaName). To reduce the blast radius of SQL generation changes, consider only prefixing with ${databaseName}. when schemaName !== "" and schemaName === databaseName (or otherwise detecting the ambiguous case), and keep the prior ${schemaName}. behavior for the common case.

Suggested change
// "Ambiguous reference to catalog or schema" error when databaseCode equals schemaName
const databaseName = this.connection.getdatabase();
const replacement = schemaName === "" ? "" : `${databaseName}.${schemaName}.`;
// "Ambiguous reference to catalog or schema" error when databaseCode equals schemaName.
// To reduce blast radius, only include the catalog when the schema name collides with it.
const databaseName = this.connection.getdatabase();
let replacement = "";
if (schemaName !== "") {
if (schemaName === databaseName) {
replacement = `${databaseName}.${schemaName}.`;
} else {
replacement = `${schemaName}.`;
}
}

Copilot uses AI. Check for mistakes.
return sql.replace(/\$\$SCHEMA\$\$./g, replacement);
}
}
Loading