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

Multiple Where clauses not working? #39

Closed
Dwebtron opened this issue Dec 17, 2018 · 3 comments
Closed

Multiple Where clauses not working? #39

Dwebtron opened this issue Dec 17, 2018 · 3 comments

Comments

@Dwebtron
Copy link

ReActiveAndroid Version: 1.4.3

Bug or Feature Request: Multiple WHERE clauses in query

Description: I'm trying to migrate from ActiveAndroid to REActiveAndroid but having some problems with multiple WHERE clause migrations.

The old way to do it in AA was like:
Note note = Select.from(Note.class).where("noteId = ?", username).where("noteContent= ?", content).fetchSingle();

Now, according to this migration guide: https://imangazalievm.gitbooks.io/reactiveandroid/migration-from-activeandroid.html we're supposed to do it this way:

List<Note> notes = Select.from(Note.class).fetch();
List<Note> notes = Select.from(Note.class).execute();
Note note = Select.from(Note.class).where("id=? AND title LIKE '?%'", 1, "Hello").fetchSingle();

There's several problems with this. First, "notes" is defined twice, Second ".execute();" cannot be resolved by Android Studio, and third (and perhaps most importantly) when I build it like the tutorial states, I get:
java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 1 parameters.

Why this change? What should I do to fix it?

@ImangazalievM
Copy link
Owner

  1. This sample is not correct:
List<Note> notes = Select.from(Note.class).execute();

I removed it from the documentation.

  1. ReActiveAndroid has a different syntax for building SELECT queries with `WHERE' clause. The sample in the documentation was incorrect and I fixed it. The correct version of the query:
Note note = Select.from(Note.class).where("id=? AND title LIKE '?%'", 1, "Hello").fetchSingle();

Thanks for your report!

@bhapps
Copy link

bhapps commented Dec 27, 2018

There is still an issue where I wish to return all (or paginated) data filtered by the query using fetch() which returns the error of Cannot bind argument at index 2 because the index is out of range. The statement has 1 parameters

All the documentation advises only of using fetchSingle() when using multiple Where clauses
I wish not to return only the first hit, but all (or some) data items.

Maybe fetch() has not been implemented for using multiple Where clauses

@cviacmob
Copy link

cviacmob commented Jan 3, 2019

How to use single column to get multiple value based on filter , given below code error . kindly solve this query
Select.from(SeasonMasterDB.class).where("state LIKE '%" + "current_season" +"old_season"+ "%'").fetchSingle();

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

4 participants