Forum Academy Marketplace Showcase Pricing Features

Prevent wrapping quotes around SQL queries?

Hey all, I am trying to pass an order by clause to my SQL query, and can’t figure out how to prevent bubble from passing a parameter without quotes. For example, a valid query would be:

where record_timestamp > '2022-08-02T19:46:35.015Z' group by name order by Volume desc limit 200

but when specifying an order from bubble, no matter what I do, it passes Volume with the quotes:

where record_timestamp > '2022-08-02T19:46:35.015Z' group by name order by 'Volume' desc limit 200

…which provides erroneous results from mysql.
Is there any workaround for this?

Not sure if this would work or if it’s a valid solution but have you tried changing your field name to ‘Volume’?

Haha that’s a good idea - didnt seem to work though. :frowning:

The SQL connector totally supports this. I use the ORDER BY clause all the time in my app. If you can paste a picture of your connector query I’ll see if I can figure it out for you.

What DB are you using? What is the type of the parameters you are passing? It seems like bubble always wraps strings with quotes.

Here’s a screenshot:

Hmmm, doesn’t look like there’s anything wrong with the syntax. Long shot, but maybe try and put a semi-colon at the end?

You’ll need to break down the issue to figure out where the problem is. So:

  1. copy your statement to a new one for debugging.
  2. Then in the new statement, try to get it working by tearing out some stuff. First remove the where clause and group by clause and try to order by name desc limit 100
  3. If that works, then the issue is either in the where clause or the group by clause or the Volume term. Try then to order by Volume. IF that works, then add the group by back in. IF that works, change the where clause…etc.

If you can show examples of what’s working and what’s breaking we can probably figure it out from there

Thanks for the suggestions! For now I’m doing the sorting in javascript on the client side, which should be fine for now. I’ll probably wrap the DB around an API anyways, but I’m sure I’ll run into something like this again!