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

Multiple update with array casting issue #741

Open
dekdevy opened this issue Nov 27, 2023 · 0 comments
Open

Multiple update with array casting issue #741

dekdevy opened this issue Nov 27, 2023 · 0 comments

Comments

@dekdevy
Copy link

dekdevy commented Nov 27, 2023

Hey, im trying to update multiple rows with a real[] column.

My approach is this:

const data = [[123, [1.2,3.4,5.6]], ... ]

UPDATE mytable as t
  SET myreal = (v.myreal)::real[]
  FROM (VALUES ${sql(data)}) AS v(id, myreal)
  WHERE t.id = (v.id)::int 

This throws a PG error: malformed array literal: "1.2,3.4,5.6". This leads me to believe that I cannot hand an array in like this as it is being cast to a string and sent directly. I found a workaround using const data = [[123, '{' [1.2,3.4,5.6].join(',') '}'], ... ].

Am I doing something wrong?

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

1 participant