-
Notifications
You must be signed in to change notification settings - Fork 298
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
CBLIS query with boolean value returns 0 result #756
Comments
CBLIS stores boolean value as 0 or 1 (CoreData boolean value) instead of true or false. Option1: Option2: |
Storing booleans as the NSNumbers 0 and 1, instead of NO and YES, seems wrong. Is it a bug in the CBLIS code, or is this something CoreData does? (Is this being caused by the problem of distinguishing NSNumbers 0/1 from NO/YES? I.e. CoreData tells us to store a YES value, but it's an NSNumber and we think it's a 1? If so, I know the workaround; see CBJSONEncoder.m, lines 178-185.) |
Each of these tests fails :
To avoid this problem, I fetch all objects and then I filter the array of NSManagedObjects. Problems :
|
The boolean value from the CoreData is NSNumber with char type ('1' or '0') and CBLIncrementalStore doesn't convert that to the correct JSON boolean value. case NSBooleanAttributeType:
result = CBLISIsNull(value) ? @(NO) : value;
break; @mastohhh When I change your unit test PR with below, the unit test pass but that's not what it should be anyway.
I plan to correct the value saved in CBL database, but currently I don't have an efficient way to correct the existing data. |
- Store boolean value in CBL database as JSON boolean value instead of number boolean value - Provide kCBLISCustomPropertyQueryBooleanWithNumber (Default is NO) to support querying the existing boolean number value. - If setting the kCBLISCustomPropertyQueryBooleanWithNumber property value to YES, when scanning the predicate for CBLQueryBuilder, CBLIS will replcate the original boolean predicate with an OR-compound predicate of the original predicate and the improvised number boolean predicate without parameterizing. For example, if the predicate is 'checked == YES', CBLIS will replace the predicate with 'checked == YES or checked == 1. #756
- Store boolean value in CBL database as JSON boolean value instead of number boolean value - Provide kCBLISCustomPropertyQueryBooleanWithNumber (Default is NO) to support querying the existing boolean number value. - If setting the kCBLISCustomPropertyQueryBooleanWithNumber property value to YES, when scanning the predicate for CBLQueryBuilder, CBLIS will replcate the original boolean predicate with an OR-compound predicate of the original predicate and the improvised number boolean predicate without parameterizing. For example, if the predicate is 'checked == YES', CBLIS will replace the predicate with 'checked == YES or checked == 1. #756
@mastohhh I have fixed the issue in the master branch. The boolean value is now stored as the JSON boolean value instead of number value from now on. I would be ideal if you could reset your data, otherwise please set customProperty kCBLISCustomPropertyQueryBooleanWithNumber with value = YES to the CBLIS store as below: [store setCustomProperties:@{kCBLISCustomPropertyQueryBooleanWithNumber: @(YES)}]; Let me know if you have any questions. |
- Store boolean value in CBL database as JSON boolean value instead of number boolean value - Provide kCBLISCustomPropertyQueryBooleanWithNumber (Default is NO) to support querying the existing boolean number value. - If setting the kCBLISCustomPropertyQueryBooleanWithNumber property value to YES, when scanning the predicate for CBLQueryBuilder, CBLIS will replcate the original boolean predicate with an OR-compound predicate of the original predicate and the improvised number boolean predicate without parameterizing. For example, if the predicate is 'checked == YES', CBLIS will replace the predicate with 'checked == YES or checked == 1. #756 # Conflicts: # Unit-Tests/IncrementalStore_Tests.m
Reported by #751.
The text was updated successfully, but these errors were encountered: