DB SC Actions - Add Upsert (postgres) and Insert / Update Duplicate Key MySql

Hi team,

Could be a bit of a time saver if among the DB Server Connect actions we also have an Insert/Update function.

For Postgres I believe this is called: Upsert (https://www.postgresqltutorial.com/postgresql-upsert/)
For MySql I believe this is called: Insert / Update on Duplicate Key (https://www.mysqltutorial.org/mysql-insert-or-update-on-duplicate-key-update/#:~:text=When%20you%20insert%20a%20new,with%20the%20new%20values%20instead.)

Currently I typically will run an initial query, then an insert/update based on this.

I’m going to be doing this with the Custom Query builder, just thought this could be a nice add-on to the DB actions in SC.

I’m going to bump this feature request, this would be a time-saver

While wappler team is working on this, current option is to use custom query can be used to write upsert queries.

Unique constraints need to be available in the native ui component to achieve this. At least from PG perspective it is required. Coz one table may have multiple unique constraints. While you’re wokring on this - just take of this please.

Also, to complement, give us an option to select which fields we want to update… For example, when inserting I have the field “created_at”, but when updating I don’t want to update this field…

Just to make this easier for the team, I have the above idea - if Value On Update field is empty, don’t update that value. So, in the above example, only “vat” column would be updated

And I guess we need a new section to see/specify the constraints like @nshkrsh said. Do you have any suggestions how to make this in the UI?

Edit for Patrick: https://knexjs.org/#Builder-onConflict

2 Likes

Bump

1 Like