Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error updating "name" column #98

Open
ksAvinash opened this issue Jun 18, 2021 · 4 comments
Open

error updating "name" column #98

ksAvinash opened this issue Jun 18, 2021 · 4 comments

Comments

@ksAvinash
Copy link

ksAvinash commented Jun 18, 2021

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
}

@lucas-subli
Copy link

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.

@brian-learningpool
Copy link

I've just stumbled upon the same bug. Any ideas when this will be patched on NPM?

@mrbayrmagnai
Copy link

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

@jansila
Copy link

jansila commented Jul 10, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants