Open ksAvinash opened 3 years ago
After hours and hours on the same problem here is the fix:
DO NOT pass two params, pass 1 or 3+ Any query with 2 params will fail
await rds.query('update users set name = :name where email = :email', { name: 'Test User', email: 'test@gmail.com', dummy: 'dummy' });
Should work. There seems to be a fix on master that has not been uploaded to NPM yet.
I've just stumbled upon the same bug. Any ideas when this will be patched on NPM?
Don't use name
, value
, cast
as property name of params. These keywords are already used in library for other purposes.
await rds.query('update users set name = :cu_name where email = :email', { cu_name : 'Test User', email: 'test@gmail.com' });
Should work
Oh, it was driving me mad for an hour, because I have a table with columns note, name
and the error for query
await db.query(`INSERT INTO InternalNotes (note, name) VALUES ( :note, :name);`, props)
is BadRequestException: Cannot find parameter: note
, so that was quite confusing as to what is going on.
const rds = require('data-api-client')({ secretArn: process.env.rdsSecretArn, resourceArn: process.env.rdsArn, database: process.env.rdsDatabase, region: process.env.awsRegion, });
await rds.query('update users set name = :name where email = :email', { name: 'Test User', email: 'test@gmail.com' });
BadRequestException: Cannot find parameter: name at Object.extractError (/<>/node_modules/aws-sdk/lib/protocol/json.js:52:27) at Request.extractError (/<>/node_modules/aws-sdk/lib/protocol/rest_json.js:55:8) at Request.callListeners (/<>/node_modules/aws-sdk/lib/sequential_executor.js:106:20) at Request.emit (/<>/node_modules/aws-sdk/lib/sequential_executor.js:78:10) at Request.emit (/<>/node_modules/aws-sdk/lib/request.js:688:14) at Request.transition (/<>/node_modules/aws-sdk/lib/request.js:22:10) at AcceptorStateMachine.runTo (/<>/node_modules/aws-sdk/lib/state_machine.js:14:12) at /<>/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request. (/<>/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/<>/node_modules/aws-sdk/lib/request.js:690:12) {
code: 'BadRequestException',
time: 2021-06-18T02:03:16.626Z,
requestId: '',
statusCode: 400,
retryable: false,
retryDelay: 51.27294113391956
}