You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to get something like the following MERGE statement running:
constrows=[{id: 1,name: "Ana"},{id: 2,name: "Peter"},]// use VALUES in fragment to trigger values helperconstvaluesFragment=sql`VALUES ${sql(rows,'id','name')}`sql`MERGE INTO "table"USING ( ${valuesFragment} ) AS "values" ( "id", "name" )...`
But this ended up throwing the UNDEFINED_VALUE, 'Undefined values are not allowed error.
After some digging i found the reason to be that the first argument of types.js:valuesBuilder() is an array of array:
so accessing the columns value for 'id' and 'name' failed because the row is an array and not the row object itself.
I think the issue for this in types.js:131 where multi is calculated from first[0] instead of just first, like in the insert helper.
After switching to just first it worked for my VALUES statement but i am not sure if i broke somehing else.
Is my assumption correct or am i using the values helper incorrectly?
Happy to submit a fix if this is actually a bug :)
Edit
Yes, i broke something. Using arrays of primitive values no longer works (like in: id IN ${psql([1, 2])}. Ended up changing the builder for in to wrap it's first parameter sent to the values builder always as a nested array.
The text was updated successfully, but these errors were encountered:
I was trying to get something like the following MERGE statement running:
But this ended up throwing the
UNDEFINED_VALUE, 'Undefined values are not allowed
error.After some digging i found the reason to be that the
first
argument oftypes.js:valuesBuilder()
is an array of array:so accessing the columns value for 'id' and 'name' failed because the row is an array and not the row object itself.
I think the issue for this in
types.js:131
wheremulti
is calculated fromfirst[0]
instead of justfirst
, like in the insert helper.After switching to just
first
it worked for my VALUES statement but i am not sure if i broke somehing else.Is my assumption correct or am i using the values helper incorrectly?
Happy to submit a fix if this is actually a bug :)
Edit
Yes, i broke something. Using arrays of primitive values no longer works (like in:
id IN ${psql([1, 2])}
. Ended up changing the builder forin
to wrap it'sfirst
parameter sent to the values builder always as a nested array.The text was updated successfully, but these errors were encountered: