Bug in trasformer


I just playing with a query transformer and I think i have found a bug.

When I ask for data of one raw it works fine:

But if I change the number to see other row's data it doesn't work

After switching of query transformer, running a query and switching the transformer back on it gives the result:

Thank you


after running this code once the object has value i wanted "result" var to have:

And the result outputs some gibberish.

Hi there, I'm just another Retool user and no js expert but a couple of things - by applying map to a simple array (which is what your getProducts.data looks like), it's then mapping all of the individual characters in the array items. If you look you can see it's not random, it's just splitting the letters into individual columns (A-u-g---2-1 etc.)

On the first bit -hard to say - but you don't need to use the 'getProducts' bit if you're in a query transformer, you can use the reserved word data, per the example code in the transformer field:

Also likely that if you do change the transformer, you would need to re-run the query I imagine.

Other than that hard to say as getProducts.data seems to be referring to different things in the transformer, and in your second fragment. What are you trying to do?


1 Like


Thanks for the reply.

looks like if you use:

return {{ getProducts.data[4] }}

And use "Save and run" Retool changes valuer of getProducts.data to the outcome of transformer. Thats why another run operates on a different getProducts.data then original

That doesn't happen if you use click "preview" instead of "save and run" and it doesn't happen if yo use data instead of {{getProducts.data}} .

So not sure if it's a bug or a feature :smiley:

Can't really imagine a scenario when this is useful so I think that could be a good idea if Retool resets the value of the query to default (as it would be without transformer) before it runs transformer after you click "save and run". Maybe it's not a bug, but would be much simpler.

Just wanted to narrow down outcome of the query to one column, remove duplicates and blank entries so I can use it in a select. Achieved now by creating separate transformer.

Many thanks

Hi there.

I actually always use a separate transformer. I find that the code can get lost in the query transformer, you need to remember it's there; whereas if a table uses a separate js transformer as it's input then that's really traceable. The other benefit is that, when debugging, you can compare the data that comes straight out of the query with the transformer. As a non-js-expert, it's normally my transformer code that's broken :slightly_frowning_face:

There's some useful syntax using formatDataAsObject to return a single 'column' from a query in this post which I came across recently

Flatten or Filter Nested JSON - Queries and Resources - Retool Forum

Often, though the query response is already in object format so you just need to use 'object.key' syntax.

For uniques, I make very frequent use of this kind of pattern using the preshipped _.uniq function from the lodash library:


You could write it in less code but I find it easy to read like this.


In a query transformer, you should refer to current result as data instead of {{ queryName.data }}

Try with the following in your query transformer:

return data['2']

What you are using the query name, the data is from the previous run when the transformer was not enabled.

Best regards

Yeah that looks much neater. Thanks for that.

Yeah I figured now. Just can't really see use for that behaviour so not sure is it bug or a feature :smiley: But well, now I know and I will just use data