-
Notifications
You must be signed in to change notification settings - Fork 594
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
ExecuteStatementCommand in lib-dynamodb failing with lists #4703
Comments
Hi @cpyle0819 , You are importing As far as I can tell, this command is a low level command to interact with dynamo using PartiQL. Please check out this doc page So in your case it would look something like: import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb";
const client = new DynamoDBClient({ region: "us-east-1" });
const docClient = DynamoDBDocumentClient.from(client);
try {
await docClient.send(new PutCommand({
TableName: "Coffees",
Item: {
'varietal': "arabica",
'profile': ["chocolate", "floral"]
}
}));
console.log("Item inserted successfully.");
} catch (error) {
console.error(error);
} Let me know if you have any other questions! |
Hey, Ran. lib-dynamodb exports the ExecuteStatementCommand so data attribute types can be avoided. It sounds like you're telling me not to use that command from lib-dynamodb. It's a documented part of the library. Is that wrong? |
Hi @cpyle0819 , I totally missed that part. Partly because we don't have an example for it anywhere! I'm able to reproduce the bug with the provided code and confirm that the serialization fails when trying to insert an array of arrays. Will add to backlog. |
Same error also gets thrown for objects: const command = new ExecuteStatementCommand({
Statement: `INSERT INTO Coffees value {'varietal':?, 'profile':?}`,
Parameters: ["arabica", { foo: "bar"}],
}); |
@RanVaknin Could the typescript defs be fixed first since I am assuming this will take some time? What seem to be happening is a parameter:
becomes
but if you nest it:
It understands the inner parts just fine:
Effectively using the document client with PartiQL becomes not practical when dealing with non-scalar values. |
In case anyone else runs into this, you'll want to import To get this working:
Do this: const { DynamoDBClient, ExecuteStatementCommand } = require('@aws-sdk/client-dynamodb');
const { marshall } = require('@aws-sdk/util-dynamodb');
const client = new DynamoDBClient({});
const command = new ExecuteStatementCommand({
Statement: `INSERT INTO Coffees value {'varietal':?, 'profile':?}`,
Parameters: marshall([
"arabica",
{ foo: "bar"}
]),
});
await client.send(statement); |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Checkboxes for prior research
Describe the bug
The
ExecuteStatementCommand
fromlib-dynamodb
is failing when given a list as a parameter.SDK version number
@aws-sdk/client-dynamodb: "^3.210.0"
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
18.12.1
Reproduction Steps
Observed Behavior
Expected Behavior
Expected the parameters array to be able to handle an array parameter.
Possible Solution
No response
Additional Information/Context
Working version with the base client:
The text was updated successfully, but these errors were encountered: