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

Support for named parameters in queries #172

Open
Gibehatman opened this issue Sep 2, 2016 · 8 comments
Open

Support for named parameters in queries #172

Gibehatman opened this issue Sep 2, 2016 · 8 comments
Assignees

Comments

@Gibehatman
Copy link

Gibehatman commented Sep 2, 2016

Hi,

I try to use a Cql query containing named parameters, such as "select * from person where first_name = :first and last_name = :last".

But when I try to set the parameters value using boundQuery.setString("firstName", "foo").setString("last_name", "bar") I got an error.

The error is the following:
java.lang.IllegalArgumentException: first is not a column defined in this metadata at com.datastax.driver.core.ColumnDefinitions.getAllIdx(ColumnDefinitions.java:266) at com.datastax.driver.core.BoundStatement$DataWrapper.getAllIndexesOf(BoundStatement.java:1364) at com.datastax.driver.core.AbstractData.setString(AbstractData.java:254) at com.datastax.driver.core.BoundStatement.setString(BoundStatement.java:449) ....

It works if I use question marks for the parameters '?'.

Am I doing something wrong, or are the named parameters not supported by scassandra?

Thanks,

@chbatey
Copy link
Member

chbatey commented Sep 5, 2016

Thanks for raising the issue. You're right these don't work yet in Scassandra. Would you be up for trying to raise a PR?

@Gibehatman
Copy link
Author

I'm really sorry, but I won't have time to create a fix :(.

@chbatey
Copy link
Member

chbatey commented Sep 9, 2016

no problem i think @tolbertam will be fixing it very soon

@tolbertam
Copy link
Contributor

👍 I'll give this ago after #171

@tolbertam tolbertam self-assigned this Oct 9, 2016
@vroldanbet
Copy link

@tolbertam did this get fixed as of #171?

@tolbertam
Copy link
Contributor

@tolbertam did this get fixed as of #171?

It was not, but I can work on this next unless someone else wants to give it a shot. The code is in place to parse the protocol level stuff, so it's just a matter of parsing for :param in the prepared query and adding it to the metadata, and then to pull the parameters from the EXECUTE request (in fact I think that might already be done).

@vroldanbet
Copy link

@tolbertam was just wondering, due to your last comment :) I'm not proficient in scala, unfortunately

@tolbertam
Copy link
Contributor

tolbertam commented Feb 1, 2017

@vroldanbet, no worries :). There is this and a few other follow ons i need to do after completing #171. I'll take a look at these next within in the next week or so.

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

No branches or pull requests

4 participants