Query GUI Mode: Bulk Update Via Composite Primary Key

Presently, the GUI mode only let's you use bulk update if your table has a single-column primary key in MySQL. However, for some data sets a composite primary key is the choice we have available. Using only a single column for the update would not correctly identify the record to update. Take the following simple example:

CREATE TABLE foo (
  user_id int(10) unsigned not null,
  location_id int(10) unsigned not null,
  rating int(3) unsigned not null,
  PRIMARY KEY(user_id, location_id)
)

In this case, I'd like to update based on the tuple of user_id and location_id, either one is insufficient to identify the record on its own.

10 Likes

@church this is a great request. For anyone viewing, this thread has some more context on what Retool current does/doesn't support: How to use composite primary key for bulk updates?

Thanks Justin, I, of course, do use the loop around a sql query via js query pattern, since I don't want to turn off placeholder parsing for the whole database connection (which would let me generate all the updates using INSERT ... ON DUPLICATE KEY UPDATE by quickly crafting a string with parenthetical lists).

However, it's a lot of work relative to the GUI mode, and enabling composite keys in bulk upserts via the GUI is much easier on me =)

1 Like

I'm new to retool and straight away encountered this problem -- in SQL there's this great word you can use with UPDATE statements, it's called "AND" -- don't know why retool haven't heard of it...

in 2023 it's still missing, let us know if it's coming to retool , thanks

Nothing yet, but let me check in with the team!

2 Likes

Would love this in the GUI for workflows as well!

Noted! No updates here yet, but as usual, will keep this thread updated. :+1:

This Feature is Highly Needed.

Another vote for this feature please!

Noted both requests - thank you!

Vote for this feature!!!!!

Noted! :+1: Thanks, Roman :slight_smile:

Another vote for this one please!

:+1: filed, thank you!

Another vote for this one please!

Noted, thank you! Will keep this thread updated with any news and please keep the +1's coming :+1:

This one is highly needed! Another vote for this please

Did this ever get created? How do you do a for loop to do one at a time using javascript?

Hey @tgomax, this has not been implemented yet. I'll update this topic when there is anything new to share. We've got a good example of looping through data and calling a query with additional scope in our docs here.