Insert into shipping failed: you must satisfy the constraint 'Shipping pkey1'

I'm pretty sure that this error message is going to be the death of me.

I am trying to copy a row in a table to the same table. My database uses the auto-increment number as the id.

In the insert a record GUI, I added some code to disregard a view columns.

{{_.omit(table1.selectedRow, ['id'],['delete'],['copy'])}}

Regardless of all of the above, I still get that annoying constraint error. Why? If I am trying to insert a new record that does not have an id, shouldn't the record just get inserted with the auto-increment number assigning the id?

Any help would be greatly appreciated.

Hey @tomm,

Just a guess here: I'm assuming you're using retool's database, right? I've had this happened to me whenever I did any changes to the column or to the table, and so I needed to reset the primary id's sequence,

Here's a post that may be of guidance.

A way of knowing if this is what causes the issue, just go to the table you're trying to add a row and try manually adding a row, it may throw an error like this:

image

1 Like

Hi @tomm :wave:

I think this may be a syntactical error. Lodash._.omit() takes in an object and an array as arguments. Try writing your query like this _.omit(table1.selectedRow, ['id', 'delete', 'copy']).