Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Setting "ORDER BY" Direction via Parameter #1842

Open
gramian opened this issue Nov 28, 2024 · 1 comment
Open

SQL: Setting "ORDER BY" Direction via Parameter #1842

gramian opened this issue Nov 28, 2024 · 1 comment

Comments

@gramian
Copy link
Collaborator

gramian commented Nov 28, 2024

ArcadeDB Version:

ArcadeDB Server v24.11.1 (build b466f487e42fbb39fd20965004ce88682335eaba/1730841732933/main)

OS and JDK Version:

Running on Linux 6.2.0-26-generic - OpenJDK 64-Bit Server VM 17.0.13

It is currently not possible to set the direction of sorting of ORDER BY via parameter (ie HTTP API, params object).
I think this is due to the parameters in the params object being placed as data types into the query, so a string is enclosed in quotes. Hence the necessary keywords ASC or DESC cannot be set, as using a parameter would result in the strings "ASC" or "DESC".

To allow control somewhat safely without allowing keywords to be passed, the grammar could allow in addition to ASC and DESC also true and false? Alternatively the sort direction could be controlled by a top-level parameter like limit, but this would then be not SQL specific and maybe expected to work with all languages.

@lvca WDYT?

Steps to reproduce

wget -qO- --content-on-error "http://localhost:2480/api/v1/query/test" --post-data='{"language": "sql", "params": { "dir": "asc" }, "command": "SELECT num FROM Test ORDER BY num :dir"}' --user=root --password=password
@gramian
Copy link
Collaborator Author

gramian commented Nov 28, 2024

The necessary changes look rather easy, every:

[ <DESC> { lastItem.type = OrderByItem.DESC; }| <ASC>  { lastItem.type = OrderByItem.ASC; }]

would become

[ (<DESC>|<FALSE>) { lastItem.type = OrderByItem.DESC; }| (<ASC>|<TRUE>)  { lastItem.type = OrderByItem.ASC; }]

And could be read as "use default direction? true / false".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant