-
Notifications
You must be signed in to change notification settings - Fork 583
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
querying boolean column #17
Comments
You could try: MyRecord.find(MyRecord.class, "Sync = 'false'"); Or, better yet: MyRecord.find(MyRecord.class, "Sync = ?", "false"); That's because of the inconsistency I mentioned in #27 I believe it should work with 0 and 1, but instead it maps booleans using String.valueOf, hence "true" and "false" in the database. On a different note, you might want to take a look at http://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html#naming, specifically "If the name you choose consists of only one word, spell that word in all lowercase letters". |
I agree with @arekolek on this and modified the storage types to 0 and 1 for boolean types. If you use it as library, it should store as 0 and 1 now. Also, there's some improvement to the inflate logic to allow for both primitive as well as Object types. Do try it out and let me know if that suits your purpose. |
@satyan you changed the way you storage Boolean type but didn changed the way you return it. It's always returning false. http://github.com/satyan/sugar/blob/master/library/src/com/orm/SugarRecord.java#L284 I changed it to Sorry, I can't make a pull request, but is only this line that need to be changed. |
@tsuharesu my bad.. it's corrected now. thanks. |
i can see that a boolean column is mapped internally by SqLite to an Integer DataType. no problem with that. but has anyone been able to use Sugar to query a boolean column?
one of my class has this variable:
boolean Sync;
when i try: MyRecord.find(MyRecord.class, "Sync = 0")
it returns no records, even though there are records there with Sync set to false. i've tried all variations on Sync=FALSE sync=false etc.
the strange thing is, if i query for "Sync > 0" i get all the records regardless of the True/False status of the records. can anyone shed some light on this? am i using the wrong syntax?
apologies in advance. new to Java...
The text was updated successfully, but these errors were encountered: