@openhi/constructs 0.0.175 → 0.0.176
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.
|
@@ -5436,6 +5436,8 @@ var DataApiPostgresQueryRunner = class {
|
|
|
5436
5436
|
}
|
|
5437
5437
|
async query(sql, params) {
|
|
5438
5438
|
await this.ensureSchemaBootstrapped();
|
|
5439
|
+
const qualifiedSql = qualifyResourcesTable(sql, this.schema);
|
|
5440
|
+
logDebugQuery(qualifiedSql, params);
|
|
5439
5441
|
const out = await this.client.send(
|
|
5440
5442
|
new ExecuteStatementCommand({
|
|
5441
5443
|
resourceArn: this.clusterArn,
|
|
@@ -5446,7 +5448,7 @@ var DataApiPostgresQueryRunner = class {
|
|
|
5446
5448
|
// `ValidationException: The schema parameter isn't supported.`
|
|
5447
5449
|
// Instead, the SQL is rewritten to schema-qualify the `resources`
|
|
5448
5450
|
// table inline before being sent. See {@link qualifyResourcesTable}.
|
|
5449
|
-
sql:
|
|
5451
|
+
sql: qualifiedSql,
|
|
5450
5452
|
parameters: params.map(toSqlParameter),
|
|
5451
5453
|
// Results as named columns so we can map them back to JS objects.
|
|
5452
5454
|
includeResultMetadata: true,
|
|
@@ -5487,6 +5489,7 @@ var DataApiPostgresQueryRunner = class {
|
|
|
5487
5489
|
}
|
|
5488
5490
|
async runBootstrap() {
|
|
5489
5491
|
for (const statement of buildSchemaBootstrapStatements(this.schema)) {
|
|
5492
|
+
logDebugQuery(statement, []);
|
|
5490
5493
|
await this.client.send(
|
|
5491
5494
|
new ExecuteStatementCommand({
|
|
5492
5495
|
resourceArn: this.clusterArn,
|
|
@@ -5498,6 +5501,18 @@ var DataApiPostgresQueryRunner = class {
|
|
|
5498
5501
|
}
|
|
5499
5502
|
}
|
|
5500
5503
|
};
|
|
5504
|
+
function logDebugQuery(sql, params) {
|
|
5505
|
+
if (process.env.DEBUG !== "true") {
|
|
5506
|
+
return;
|
|
5507
|
+
}
|
|
5508
|
+
console.log(
|
|
5509
|
+
"[pg-debug]",
|
|
5510
|
+
JSON.stringify({
|
|
5511
|
+
sql,
|
|
5512
|
+
params: params.map((p) => ({ name: p.name, value: p.value }))
|
|
5513
|
+
})
|
|
5514
|
+
);
|
|
5515
|
+
}
|
|
5501
5516
|
function qualifyResourcesTable(sql, schema) {
|
|
5502
5517
|
return sql.replace(
|
|
5503
5518
|
/(\b(?:FROM|JOIN)\s+)resources\b/gi,
|