Inconsistent behaviour passing control values into queries

Hi again,

I seem to be experiencing inconsistent behaviour when passing control values (e.g. from select and textinput fields) inot queries to be executed against a Postgres DB.

Much of the time, controlname.value seems to deliver the desired data into the query, but sometimes this results in a 1-length array of values being passed in, resulting in the same bit of data with curly brackets, all in the resulting string together, being passed in. (i.e. the string in the table cell then being “{data}” and even in some cases in uuid fields ("{3a1a335b-2e8e-410c-8ac2-c0a6b1118ec3"}) which obviously is not accepted, and a query error is thrown.

I’m not sure how I am triggering this behaviour - can anyone tell me what is going on?

I can put {{~.value[0]}} in each relevant reference, but concerned that this will break things when it isn’t passing an array.

I am calling a stored procedure using a ‘CALL…’ SQL query, not sure if this is the problem and it simply hasn’t been properly implemented as many of retool’s customers don’t go this way?

Update: as expected, the addition of ‘[0]’ to each affected control value reference was disastrous - when the behaviour reverted to normal, each reference passed a string as expected instead of an array, and the result was to cut off all but the first character of the string.

This is a significant problem if the above behaviour is not understood and we can’t predict when it will occur.

Another update:

here are two select controls, from different tabs on the same retool app, both populated from the same DB table.

This first one shows the selected value is available directly:

This second one shows the value member contains an array with one item in it. This seems to change, and I don’t know why. As soon as you reference it using ~.value[0], it’s fine while this behaviour is continuing, but then when it stops, ~.value[0] returns only the first character of any string that value contains.

Just to be clear, I have observed this behaviour with select controls and textinput controls. I may have seen it in datepickers too, but didn’t confirm that at the time.



Hey @jconroy – sorry about this issue and the delayed reply. Can you share a screenshot of how you have the values input configured for the dropdown (i.e. single select) component? It should be expecting an array in the values input and then when you access the selected value with {{select1.value}} in your query, that should return a single value.

On the other hand, if you are using a multiselect component, that component will return an array of values when you use {{multiselect1.value}} in your query. This is true even if you only have one value selected.

1 Like