yahoo / squidb

SquiDB is a SQLite database library for Android and iOS
https://github.com/yahoo/squidb/wiki
Apache License 2.0
1.31k stars 132 forks source link

Upsert validation enhancements #262

Closed sbosley closed 7 years ago

sbosley commented 7 years ago

This PR implements regex-based uniqueness validation for the upsert plugin, replacing both the generated Index and the order field for multi-column upsert keys. We now simply check to make sure that the user has explicitly specified either a uniqueness or primary key constraint for exactly the set of columns annotated with @UpsertKey. This is safer because it doesn't require the user to remember to create the autogenerated index, and lets the constraint itself inform the index ordering rather than requiring the order field in the annotation. (The order of the criterion construction doesn't matter because the SQLite query optimizer can reorder terms in an AND clause to take advantage of indices).