realm / realm-browser-osx

DEPRECATED - Realm Browser for Mac OS X has been replaced by realm-studio which is cross platform.
https://realm.io
503 stars 54 forks source link

Programmatically construct search predicates in a saner way #314

Closed bdash closed 7 years ago

bdash commented 7 years ago

Convert search terms into NSExpressions and assemble them into NSComparisonPredicates, which are then combined into a NSCompoundPredicate. This is preferable to building up format strings because it completely sidesteps the need to worry about escaping any special characters.

I also switched to using NSNumberFormatter to parse integers and floating point values from strings. This avoids having a search term of "1.2" match any integer column with a value of 1, which seemed like confusing behavior. It also results in more consistent handling of whitespace around numbers, which previously differed between zero and non-zero values (" 0" would be ignored, while " 1" would be respected).

I've only lightly tested this.

Fixes #313.