Budibase / budibase

Low code platform for building business apps and workflows in minutes. Supports PostgreSQL, MySQL, MariaDB, MSSQL, MongoDB, Rest API, Docker, K8s, and more 🚀
https://budibase.com
Other
22.47k stars 1.55k forks source link

[BUDI-7762] Error saving queries with brackets () in URL #12424

Closed Meldiron closed 11 months ago

Meldiron commented 11 months ago

Checklist

Hosting

Describe the bug

REST API I want to use as datasource support filters, but it uses very specific query syntax. Following is how you do something like LIMIT 1 in SQL:

?queries[]=limit(1)

Here is sample request and response from HTTPie:

CleanShot 2023-11-22 at 21 47 51@2x

Sadly, adding this to Budibase results in an error.

To Reproduce Steps to reproduce the behavior:

  1. Create REST API datasource
  2. Create query
  3. Write query with URL that includes parameters where value contains ( or ), for example https://google.com?q=Hello(World
  4. Click Send, seems to work fine
  5. Click Save, shows error Error saving query

Expected behavior

No error, saving is successful.

Screenshots

CleanShot 2023-11-22 at 21 48 21@2x

App Export

Not necessary I believe, very easy to reproduce.

Additional context

Open to contributing if you can point me to places ✨ Sadly, I won't be able to find the bug as I haven't contributed to Budibase yet.

From SyncLinear.com | BUDI-7762

Meldiron commented 11 months ago

In network tab I can see response from POST /api/queries is {"message":"Invalid query name","status":400}.

Name in payload seems to be cloud_appwrite_io v1 databases main collections reminders documents?queries[]=limit(100)

Meldiron commented 11 months ago

On the same note, I cannot get pagination to work because if those specific requirements for parameters.

For cursor pagination, I would need to send those two parameters:

?queries[]=limit(5)&queries[]=offset(10). Can yo usee a way to do that in Budibase?

melohagan commented 11 months ago

Hey @Meldiron

A couple of ideas:

  1. Instead of directly using brackets in the URL, you could try using a binding instead. (https://docs.budibase.com/docs/rest-bindings)
  2. Have a look at the appwrite custom datasource plugins: https://github.com/melohagan/budibase-datasource-appwrite
Meldiron commented 11 months ago

Hey there 👋

  1. That works, thanks ❤️

  2. I checked it and found the method used to list documents: https://github.com/melohagan/budibase-datasource-appwrite-databases/blob/main/src/datasource.ts#L33 There is third parameter queries array, where stuff like filtering, pagination or sorting can be done. In the datasource plugin, this queries parameter is not being provided, so it doesn't help me understand how to paginate Appwrite database in Budibase.

melohagan commented 11 months ago

Have raised an issue against that plugin repo: https://github.com/melohagan/budibase-datasource-appwrite-databases/issues/1

Thanks for the suggestion!

melohagan commented 11 months ago

Hey @Meldiron

I have updated the appwrite-databases connector to support queries 👍