sqlpage / SQLPage

Fast SQL-only data application builder. Automatically build a UI on top of SQL queries.
https://sql.datapage.app
MIT License
1.57k stars 89 forks source link

Behavior of multiple GET parameters with same name #630

Closed vtzi closed 1 week ago

vtzi commented 1 week ago

My understanding is that there is no standard way of handling multiple GET parameters with the same name but most web frameworks support this:

http://localhost:8080?tag=t1&tag=t2

while SQLpage requires appending [] brackets explicitly (to at least one of the parameters), eg:

http://localhost:8080/?tag[]=t1&tag=t2

Not a huge deal but makes the urls ugly, imho.

WDYT about adding support for the former as well?

lovasoa commented 1 week ago

If we created a json array for multiple parameters with the same name, this would force you to write special code to handle both the case when there is one value and the case when there is more than one. We could have tag=t1&tag=t2 generate the same thing as SET tag = '["t1", "t2"]', but just tag=t1 would still generate a SET tag = 't1', not SET tag = '["t1"]'. Then if you wanted to access the first tag, for instance, you wouldn't know whether to use $tag->0 (when there are multiple tags) or $tag (when there is a single tag).

The advantage of the bracket syntax is that it works even for a single tag. tag[]=t1 in the URL generates SET tag = '["t1"]',

vtzi commented 1 week ago

I see and agree the current handling is more consistent. Closing the issue. Thanks!