SQL update row in place

Hi I'm using postgresql, I created a table in retool, a select query to populate it, made some columns updatable, and linked a bulk update query to the table.

This is the table

This is the query:
image

This is how I bind the table to the query:

image

Now I edit a row in place, press return and click "Save".
No errors, the table reload and the data has not changed! :frowning:

Refresh shows data has not changed at all.

Then, because there's no way to inspect the SQL query being actually executed, I added "show confirmation modal before running" in advanced query settings (so I can see the selectedRow object being sent) and it actually shows an alert with the old data!
image

Please advise!

Hi there! The selectedRow property contains the original values that are loaded into the table, not the updated ones. The changes that a user makes are saved inside the recordUpdates property, as well as the changeSet property I believe.

Since the editable table features are meant to allow for editing multiple rows, recordUpdates is an array of all rows that have changes and you’ll need to accommodate a bulk update in the bulk update query. The GUI mode’s bulk update action type is streamlined for that use case!

Hi. I don't understand your answer here. I understand that you don't want to use selectedRow. However are you saying that the SQL query above should be modified to something like set email = {{table1.recordUpdates.data.email}}? Or are you saying this can't be done. You also say "you'll need to accommodate a bulk update in the bulk update query" and I'm not sure what that means. The documentation around bulk update query is very sparse, as pointed out in the forum in several places. It would be most useful if you could take the well documented question above and show how exactly it needs to be modified to get the result needed for a pretty essential use case. Also as pointed out in the forum the Bulk update action part of the interface has been converted to Events, and so you could kill two birds with one stone by pointing out how to use an Event to accomplish this. Thanks

Hi Michael,

You should be able to set up a pretty simple query to perform these updates like so:



As you can see I have set up an event handler on the table "save changes" event which triggers the table1SaveChangesHandler query.
This query is set up using GUI mode to perform a bulk update by primary key, and we provide {{table1.recordUpdates}} as the array of records to update.

Let me know if this makes sense!