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

Implemented case-insensitive, diacritic-insensitive and normalized operations for strings. #230

Open
wants to merge 35 commits into
base: master
Choose a base branch
from

Conversation

cicciotti-privatewave
Copy link
Contributor

Two user-defined functions are registered with sqlcipher: ECDSTRINGBETWEEN, which implements the BETWEEN operator, and ECDSTRINGOPERATION which implements all other operators.

If I understand the predicate syntax correctly, we can't have case-insensitive IN/CONTAINS operators that operates on collections, for string operations they have to act like string search operators. This is how I implemented them. I didn't check if Core Data coerces collections to strings when string options are specified, or if the string options are ignored if the container operand is a collection, though.

I haven't tested it a lot, but it seems to work. I can write tests if necessary.

cicciotti-privatewave and others added 30 commits March 18, 2016 18:05
…erations for strings. Two user-defined functions are registered with sqlcipher: ECDSTRINGBETWEEN, which implements the BETWEEN operator, and ECDSTRINGOPERATION which implements all other operators.
…eight migration caused the migration to incorrectly return NO and trigger an assertion without error.

- Method now relies on the entity version hashes and does not append the test for equivalence onto the check for old and new models.
…erations for strings. Two user-defined functions are registered with sqlcipher: ECDSTRINGBETWEEN, which implements the BETWEEN operator, and ECDSTRINGOPERATION which implements all other operators.
…nil too

- Fixed issue where using NSMigratePersistentStoresAutomaticallyOption without an existing managed object model caused a crash.
- Added compatibility check for persistent store coordinator's managed object model.
* Fixed issue where having equivalent models when performing a lightw…
…ity has less relationships than the old entity

-bug was first discovered when doing migrate and then calling "addPersistentStoreWithType.." which returned nil and also error nil
…igration_when_updated_entity_has_less_relationships

added fix for bug when doing a lightweight migration
Fix for issue removing all objects from a many-to-many relationship
Fixing (null) column name in relationship table
…eviousRelationships

Fixed doubled assignment to firstOrderColumn in previousRelationships…
…ing type NSUInteger, which is 32 bits wide on 32 bit platforms. Explicitly cast the result value of sqlite2_value_int64 to NSUInteger to fix implicit truncation warnings on 32 bit
…indings: into -parseExpression:inPredicate:inFetchRequest:operator:operand:ofType:bindings:: the new argument points to a Class variable where the type of the parsed operand (if it can be determined) is returned
…TRINGOPERATION, which doesn't need LIKE patterns to implement CONTAINS, ENDSWITH and STARTSWITH, and doesn't need LIKE patterns to be translated from NSPredicate to SQL syntax: if a comparison predicate is implemented with ECDSTRINGOPERATION, parse both expressions again, without any formatting, escaping etc. of the operands
…erand> IS NULL" would check for an operand without bindings to detect NULL, mistaking key path expressions for NULLs. Instead, check that the right operand is, in fact, NULL. Also support expressions of the form "NULL == <operand>" (which translate to "<operand> IS NULL")
…erations for strings. Two user-defined functions are registered with sqlcipher: ECDSTRINGBETWEEN, which implements the BETWEEN operator, and ECDSTRINGOPERATION which implements all other operators.
…ing type NSUInteger, which is 32 bits wide on 32 bit platforms. Explicitly cast the result value of sqlite2_value_int64 to NSUInteger to fix implicit truncation warnings on 32 bit
…indings: into -parseExpression:inPredicate:inFetchRequest:operator:operand:ofType:bindings:: the new argument points to a Class variable where the type of the parsed operand (if it can be determined) is returned
…TRINGOPERATION, which doesn't need LIKE patterns to implement CONTAINS, ENDSWITH and STARTSWITH, and doesn't need LIKE patterns to be translated from NSPredicate to SQL syntax: if a comparison predicate is implemented with ECDSTRINGOPERATION, parse both expressions again, without any formatting, escaping etc. of the operands
…erand> IS NULL" would check for an operand without bindings to detect NULL, mistaking key path expressions for NULLs. Instead, check that the right operand is, in fact, NULL. Also support expressions of the form "NULL == <operand>" (which translate to "<operand> IS NULL")
…encrypted-core-data into string-operations

* 'string-operations' of github.com:cicciotti-privatewave/encrypted-core-data:
  The previous code to parse "<operand> == NULL" to translate into "<operand> IS NULL" would check for an operand without bindings to detect NULL, mistaking key path expressions for NULLs. Instead, check that the right operand is, in fact, NULL. Also support expressions of the form "NULL == <operand>" (which translate to "<operand> IS NULL")
  Better detection of string vs aggregate form of IN and CONTAINS operators
  LIKE, CONTAINS, ENDSWITH, STARTSWITH etc. are now implemented by ECDSTRINGOPERATION, which doesn't need LIKE patterns to implement CONTAINS, ENDSWITH and STARTSWITH, and doesn't need LIKE patterns to be translated from NSPredicate to SQL syntax: if a comparison predicate is implemented with ECDSTRINGOPERATION, parse both expressions again, without any formatting, escaping etc. of the operands
  Change -parseExpression:inPredicate:inFetchRequest:operator:operand:bindings: into -parseExpression:inPredicate:inFetchRequest:operator:operand:ofType:bindings:: the new argument points to a Class variable where the type of the parsed operand (if it can be determined) is returned
  Fix ECDSTRINGOPERATION's implementation of LIKE
  NSPredicateOperatorType and NSComparisonPredicateOptions have underlying type NSUInteger, which is 32 bits wide on 32 bit platforms. Explicitly cast the result value of sqlite2_value_int64 to NSUInteger to fix implicit truncation warnings on 32 bit
  Implemented case-insensitive, diacritic-insensitive and normalized operations for strings. Two user-defined functions are registered with sqlcipher: ECDSTRINGBETWEEN, which implements the BETWEEN operator, and ECDSTRINGOPERATION which implements all other operators.
  Implemented case-insensitive, diacritic-insensitive and normalized operations for strings. Two user-defined functions are registered with sqlcipher: ECDSTRINGBETWEEN, which implements the BETWEEN operator, and ECDSTRINGOPERATION which implements all other operators.

# Conflicts:
#	Incremental Store/EncryptedStore.m
@cicciotti-privatewave
Copy link
Contributor Author

This should be it. It passes all tests now, it implements the little-known "n" option (NSNormalizedPredicateOption), it doesn't need to use PRAGMA case_insensitive_like... I forget what else. I think it's better than the current implementation

…_sensitive_like: we can use ECDSTRINGOPERATION
@DanielBroad
Copy link
Contributor

Build failing on the example app?

@cicciotti-privatewave
Copy link
Contributor Author

Both IncrementalStoreDemo and FailedBank compile fine on my machine (Xcode 7.3.1), for all targets. I see the Travis build had an issue but I'm not sure why? It seems xctool crashes when compiling for the iPhone 5 simulator. Not sure what I can do

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

Successfully merging this pull request may close these issues.

5 participants