onDuplicateKeyUpdate
i'm having problems using
onDuplicateKeyUpdate
,
doing it like
causes an error TypeError: Cannot read properties of undefined (reading 'name')
and doing it with set: { id: myTable.id }
causes an error TypeError: Converting circular structure to JSON
my goal is to update the whole entry/row when there's a conflict in the primary key which based on the name onDuplicateKeyUpdate
gets triggered with44 Replies
fkkkkkk 🤣
i found the way
so i just did
and do the same as
id: sql`${myTable.id}
for the rest of the columns
new problem
doing this seems to update the value to the previous one making the update worthless, but it does help in not throwing an error when inserting several batches of data
now let's say i have
using this one
now doing this will update my lastupdated but not the messageI believe you need to use
target
to let it know where is the conflictso how do i get the value being inserted to be used on the
onDuplicateKeyUpdate
set
does that property exist? cause intellisense only shows set
and no target
or where
propertySQL Insert - DrizzleORM
Drizzle ORM | %s
yeah that's the old method which does not exist in the version i am using which is version ^0.28.6
this one checks using the sql's
ON DUPLICATE KEY UPDATE
thingdo
so the only problem i now have is how do i get the current value being inserted and pass it on the set
as i said, the value i am inserting is an ARRAY or Values
well it can't be, it has to be an object
the above code will work, its exactly what im doing in my code
that's the problem i am facing now, how do i get the current value being inserted
So value is an array?
take drizzle out of the equation; how would you get the current value ?
the problem of doing this is, i would have to loop and it would cause several transactions instead of just 1
this doesnt seem like a drizzle issue
yup
array of entries
I don't think that's possible