-
Notifications
You must be signed in to change notification settings - Fork 13
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
Does the RDSDataService support array parameters? #9
Comments
Hey @arcturial thank-you for reaching out to us with your issue, I am a bit confused and was not able to reproduce it, can you please share your complete code and the API you are trying to use from |
I am using version 2.585.0 of the SDK with:
This results in I can also replicate this via the AWS CLI using.
|
I'm also experiencing the same thing, but with a string array from a lambda in us-east-2 with the Node 12.x runtime. Here's the exception that I'm getting:
|
Apologies for late reply @arcturial @theBenForce. According to the Please reach out if you have any additional questions. |
Thanks for the reply @ajredniwja. Do you know when this feature will be implemented? |
I'd also like to know when this feature will be made available. |
Hey @theBenForce @jackstevenson, The SDK team has already things set up, its up-to the service team the time they take to implement it. Will update if they implement the feature. |
I would also like to throw my weight behind this request |
Has anyone found a work around for this issue? |
Hi, i have the same problem with an array of strings and solved it with the following code. But be carful on getting SQL injections. In my case I get the data from another DB request, therefore I am fine with this solution. /**
* Includes a string in single quotes. Should be used to
* convert (map) array elements so they can be used in:
* SELECT ... WHERE foo IN ( array.toString() )
*/
function addSingleQuotesToArrayElementMapper(element) {
return `'${element}'`;
}
function createSqlStatement(stringValues) {
return `
...
WHERE stringValues IN (${stringArray.map(addSingleQuotesToArrayElementMapper).toString()})
`;
}
const databaseResponse = await RDS
.executeStatement({
// ...
sql: createSqlStatement(stringValues),
}) |
Adding to bmacher's solution - In Postgres, we can run ANY instead of IN. The advantage is that we can cast a parameter to an array (hence avoiding SQL injection):
This works, but I should add that the "::" does make me nervous since the ":" is used to find variables. In addition, I want to use "data-api-client" for formatting and that uses the "::" for dynamic identifiers. In my single test, it does seem to work there as well. Any feedback would be appreciated... |
Still getting |
Another work around is to pass each item of the array as a separate parameter:
|
This is a big issue for me because I need to execute a |
Ran into this issue as well, my workaround was to create the array as a string and cast it.
|
Hey! |
I could not create any successful workaround with the code snippet you gave. Additional search pointed me to this more explicit example: https://github.com/koxudaxi/local-data-api#how-to-insert-array-data-into-postgresql
In my case however that did not work.
with paramters looking like:
That gives me:
BTW:
|
I'm not the best person to answer this as I'm not that proficient in SQL but I believe the issue is that when you do Have you tried with: I think this needs a bit of trial and error but the main point is that after Hope this helps :) |
Thanks for the idea. Unfortunately I get the same error with:
And it is also understandable, because @silviuglv, could you please elaborate how you got the casting workaround to work? Perhaps I can apply that to my use case as well. Thx for the reply. |
Reached out to the RDS team again for them to work on it but I am not sure about the priority of it. |
Bump, it seems like a basic functionality, it does make the use of DataAPI pointless if it cannot support the core datatypes of the database. Please take this up! |
thumbsup, it's a relatively an important and basic function. |
is this feature to use Array parameters is possible anytime near soon? this would be super helpful if available |
Base on @sambs workaround:
|
Hello @frankisans I did try this option but i see same error |
Hi @rakesh-saiga I use this solution with @aws-sdk/client-rds-data v3.72 with lambda function and is working fine. |
i see, in my case error was when using go library of rds-data package. hence may be the issue we are seeing are different |
@frankisans workaround works for me. Pretty bonkers this isn't supported, what does |
@sambs @frankisans thank you so much for this. After hours of dead ends, I finally got it to work with your solutions |
Here's a bit of a shim per @frankisans fix https://gist.github.com/lefnire/26d72911ee7fb7dcf82fc5d919d192a5 |
Backlog item in queue in the service team backlog. As of now, we can't share specific timelines on when this might be implemented in GitHub. Reached out to service team for the update. Closing this issue since it is tracked in the service team's backlog. The feature, once supported by service team, should be available to all SDK(s) automatically, with API documentation updated. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Confirm by changing [ ] to [x] below:
I am encountering an error when trying to use the "arrayValue" parameter for the RDSDataService, it results in the "Array parameters are not supported." error.
My request looks like this
This is how the documentation seems to format the packet, am I doing something wrong?
The text was updated successfully, but these errors were encountered: