Giter Site home page Giter Site logo

Comments (6)

dawidk92 avatar dawidk92 commented on May 29, 2024 1

It works as expected right now. Thank you @ruicsh ❤️

from dynoexpr.

ruicsh avatar ruicsh commented on May 29, 2024

hi @dawidk92 thanks for your missing feature report. It's implemented on 2.14.0. I don't have access to a DynamoDB right now, if you could test this out. I think you always need 2 args to list_append, one of them being the key

const params = dynoexpr({
  Update: { numbersArray: 'list_append([1, 2], numbersArray)' },
});

/*
{
  UpdateExpression: 'SET #neb9c = list_append(:v4136, #neb9c)',
  ExpressionAttributeNames: { '#neb9c': 'numbersArray' },
  ExpressionAttributeValues: { ':v4136': '[1, 2]' },
}
*/

from dynoexpr.

dawidk92 avatar dawidk92 commented on May 29, 2024

Hi @ruicsh it's almost fine but it has a minor bug.

ExpressionAttributeValues returns value as a string:
{ ':v4136': '[1, 2]' }

and it should be returned as an array:
{ ':v4136': [1, 2] }

DynamoDB throws this error:
ValidationException: Invalid UpdateExpression: Incorrect operand type for operator or function; operator or function: list_append, operand type: S

from dynoexpr.

ruicsh avatar ruicsh commented on May 29, 2024

hey, fixed it on v2.14.1:

const params = dynoexpr({
  Update: { numbersArray: 'list_append([1, 2], numbersArray)' },
});

/*
{
  UpdateExpression: 'SET #neb9c = list_append(:veb45, #neb9c)',
  ExpressionAttributeNames: { '#neb9c': 'numbersArray' },
  ExpressionAttributeValues: { ':veb45': [1, 2] },
}
*/

from dynoexpr.

dawidk92 avatar dawidk92 commented on May 29, 2024

@ruicsh it works fine with an array of numbers but it doesn't work with an array of strings:

const params = dynoexpr({
  Update: { stringsArray: 'list_append(["a", "b"], stringsArray)' },
});

/*
{
  UpdateExpression: 'SET #neb9c = list_append(:veb45, #neb9c)',
  ExpressionAttributeNames: { '#neb9c': 'stringsArray' },
  ExpressionAttributeValues: { ':veb45': [null] },
}
*/

DynamoDB throws an error:
Error: Special numeric value NaN is not allowed

I created a temporary hack in my app where I put the output of the previously (v2.14.0) created value from ExpressionAttributeValues to JSON.parse() and it works just fine. Maybe that would be a solution to that problem.

from dynoexpr.

ruicsh avatar ruicsh commented on May 29, 2024

yea, fixed it on v2.14.2

from dynoexpr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.