Skip to content

Parametrized queries permitted? #517

@ashi1702

Description

@ashi1702

Hey! I was migrating to this plugin but fell short at running parametrized SQL queries.

Example:
awsClient.query('SELECT * FROM table where uuid = $1', [ 'MY_UUID' ]);

I believe this is an out of the box functionality when using the pg package.

error stack:

Error during database operations: error: there is no parameter $1
    at MY_PROJECT_PATH/api-db-pkg-v2/node_modules/pg/lib/client.js:545:17
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async file://MY_PROJECT_PATH/api-db-pkg-v2/node_modules/aws-advanced-nodejs-wrapper/dist/common/lib/plugins/default_plugin.js:57:53
    at async NullTelemetryContext.start (file://MY_PROJECT_PATH/api-db-pkg-v2/node_modules/aws-advanced-nodejs-wrapper/dist/common/lib/utils/telemetry/null_telemetry_context.js:22:12)
    at async DefaultPlugin.execute (file://MY_PROJECT_PATH/api-db-pkg-v2/node_modules/aws-advanced-nodejs-wrapper/dist/common/lib/plugins/default_plugin.js:57:12)
    at async NullTelemetryContext.start (file://MY_PROJECT_PATH/api-db-pkg-v2/node_modules/aws-advanced-nodejs-wrapper/dist/common/lib/utils/telemetry/null_telemetry_context.js:22:12)
    at async HostMonitoringConnectionPlugin.execute (file://MY_PROJECT_PATH/api-db-pkg-v2/node_modules/aws-advanced-nodejs-wrapper/dist/common/lib/plugins/efm/host_monitoring_connection_plugin.js:69:16)
    at async NullTelemetryContext.start (file://MY_PROJECT_PATH/api-db-pkg-v2/node_modules/aws-advanced-nodejs-wrapper/dist/common/lib/utils/telemetry/null_telemetry_context.js:22:12)
    at async FailoverPlugin.execute (file://MY_PROJECT_PATH/api-db-pkg-v2/node_modules/aws-advanced-nodejs-wrapper/dist/common/lib/plugins/failover/failover_plugin.js:176:14)
    at async NullTelemetryContext.start (file://MY_PROJECT_PATH/api-db-pkg-v2/node_modules/aws-advanced-nodejs-wrapper/dist/common/lib/utils/telemetry/null_telemetry_context.js:22:12) {
  length: 94,
  severity: 'ERROR',
  code: '42P02',
  detail: undefined,
  hint: undefined,
  position: '33',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'parse_expr.c',
  line: '893',
  routine: 'transformParamRef'
}

i've setup the awsClient using the docs at Aws Driver Examples

With the same setup i am able to successfully execute:
awsClient.query(SELECT * FROM table where uuid = 'MY_ID')

I'm using AwsPGClient with pooling.

const poolConfig = new AwsPoolConfig({
  idleTimeoutMillis: 10000,
  allowExitOnIdle: true
})

const provider = new InternalPooledConnectionProvider(poolConfig)

const params = {
  plugins: 'readWriteSplitting,efm',
  connectionProvider: provider
}

AWS_CLIENT = new AwsPGClient({
  user: postgres.pguser,
  host: postgres.pghost,
  database: postgres.pgdatabase,
  password: postgres.pgpassword,
  port: postgres.pgport,
  ssl: { rejectUnauthorized: false },
  ...params
})

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpending releaseResolution implemented, pending official release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions