Retool GUI Query to Update a Single Record Not Working as Expected

I have a Retool query using the GUI config that updates a single record in a snowflake database.

When I preview the query, the output shows numberOfRecordsThatWouldBeUpdated: 1, however when I run the query I get the error:

statusCode:422
error:"Unprocessable Entity"
message:"Updating multiple records with this query has not been enabled."

My query was working no problem up until yesterday and I didn’t make any changes. The only way I can get it to work now is to check “Allow this query to modify multiple rows in the database?” (what exactly does this do?)

I’ve confirmed there are no duplicates in my database. I think this might be a new Retool bug.



2 Likes

@sgodoshian Hmmm interesting.

Could you share/export app JSON for me to clone and try to reproduce?

That is so odd the checkbox fixes the issue. I was have guessed that the box would throw an error and turning it off would fix it :sweat_smile:

Not sure what the box checking is doing under the hood, my guess is that it might be modifying something in the query during query build.

My guess is that the box turns off the error checking, with the bug being in the detection of how many rows are being updated. Which is somehow coming back as a false positive even though the preview confirms the query is set up to only modify one row as intended...

1 Like

Hi @Jack_T!

The issue is still present and I create a new app to demonstrate it:
BUG - snowflake update single record.json (42.0 KB)

Here's a video as well:
retool-gui-update-query-builder-snowflake-bug.mp4

Were you able to get any information on what's happening under the hood when "Allow this query to modify multiple rows in the database?" is checked/unchecked?

Thanks for the help!

Hello @sgodoshian!

Sorry for the late response. I tested out an update query with Snowflake and did not get that error message.

May I ask which version of retool you are on? My hopes is that this error was patched :sweat_smile: :crossed_fingers:

Given that you said in the original post things were working fine previously, I would imagine the bug might have snuck through in an update...

I just tried toggling the "Allow query to modify multiple rows in the database?" and was greeted with a modal asking me to confirm this is what I want

So my guess is that there were some engineering attention on this very recently to get things sorted :technologist: let me know if it still requires a check box to update a single row!

I haven't seen any other resource queries with this option, so I am guessing the functionality is unique to snowflake being able to potentially update way too much/all data and needing more under the hood query transformation by the Database Connector.

Hey @Jack_T !

I'm still able to reproduce the issue. The update query does not work unless I check Allow this query to modify multiple rows in the database?

2024-07-22_11-07-51

Ahhh that's unfortunate :sweat_smile:

Are you self hosted/what version of Retool are you using? In the GIF you shared I did not see the modal pop up that I had when toggling the check box so I still have hope that updating things might fix the error message.

My guess for why the error is popping up is that there are multiple rows with the same ID (in your example ID 1). But you did run the query preview and it said you were only modifying one entry.....

Is there any other issues caused by leaving this checked? I tried to reproduce it on the latest version of Retool and couldn't get the error to show up for me :sweat:

Hey @Jack_T !
My org is using Retool Cloud on business plan, so I believe we're always on the latest version of Retool?

I didn't notice that the popup was missing, but I had seen it the day I created that screen recording (as I tested it to see if the issue was fixed, and then I made the recording). Perhaps it just didn't pop up a second time? :thinking:

We've discovered that we can switch to plain SQL queries for our Updates and avoid having to check that checkbox (which is only visible for GUI queries). So we'll just roll with that for now.

Could you follow up on what checking/unchecking Allow this query to modify multiple rows in the database? does? Thanks for all your help!

Hello @sgodoshian!

Yes that is correct, if you are on Retool Cloud you will always ben on the latest version :sweat_smile:

Interesting that the popup did appear for you, maybe it turns off after a certain number of toggles? :thinking:

I am so happy you found a work around! I didn't know Snowflake could take plain SQL queries but that is really good to know. We are planning an overhaul of our Snowflake GUI!

Can follow up on the purpose of the checking toggle. I imagine that in our database connector it might be a param that Snowflake is looking for, but maybe it is for our internal query builder to better create raw SQL that fits best with what Snowflake is expecting :nerd_face:

1 Like