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

ORDER BY does not work with addParameter #332

Open
gphendry opened this issue Jul 29, 2019 · 2 comments
Open

ORDER BY does not work with addParameter #332

gphendry opened this issue Jul 29, 2019 · 2 comments

Comments

@gphendry
Copy link

Currently using query.addParameter to specify custom parameters in an ORDER BY clause does not work properly.

In a query like:

String sql = "SELECT * " +
             "FROM report_A" +
             "ORDER BY :order :sequence "+
             "LIMIT :from, :limit";

When calling addParameter to substitute a custom value for :order the custom value is completely ignored and treated as blank.

The only way to pass custom ORDER BY parameters currently is to manually concatenate them into the original query string like so:

String sql = "SELECT * " +
         "FROM report_A" +
         "ORDER BY " + order " " + SEQUENCE +
         "LIMIT :from, :limit";

Which seems inconsistent with how every other parameter is treated.

@skradel
Copy link

skradel commented Dec 16, 2019

SQL/JDBC don't work this way and this has nothing to do with sql2o -- for example, you also cannot pass table/view/schema/column identifiers in as parameters.

@aaberg
Copy link
Owner

aaberg commented Dec 16, 2019 via email

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

3 participants