jeremydaly / data-api-client

A "DocumentClient" for the Amazon Aurora Serverless Data API
MIT License
439 stars 61 forks source link

question: am i unable to query using a uuid? #70

Closed mlg87 closed 3 years ago

mlg87 commented 3 years ago

ive been trying to track down an answer to my issue all day. when running a simple query (looking up a user by id for instance) i am getting this error:

image

i just looked at the aws js sdk docs and noticed there is no param type that directly correlates to uuid

image there is also this note on the aws data api general docs

image

so my question is can this really not handle querying with a uuid?

mlg87 commented 3 years ago

using the the aws-sdk directly, i tried the following:

const AWS = require('aws-sdk')
const data = new AWS.RDSDataService({
  region: 'us-east-2'
});

const main = async () => {
  const read = await data.executeStatement({
    secretArn: 'arn:aws:secretsmanager:us-east-2:XXXXXXXXX:secret:blah-blah',
    resourceArn: 'arn:aws:rds:us-east-2:XXXXXXXXXX:cluster:blah-blah',
    database: 'postgres',
    sql: 'SELECT * FROM users WHERE id = :id',
    parameters: [
      { name: 'id', value: { stringValue: 'some-valid-uuid-for-a-user' } }
    ]
  }).promise()

  console.log('read', read);

}

main();

and got the same error, so i cast the id param and it worked.

sql: 'SELECT * FROM users WHERE id = :id::uuid',

annoying, but i will find a way around