AlexDenisov / iActiveRecord

ActiveRecord for iOS without CoreData, only SQLite
http://alexdenisov.github.com/iActiveRecord/
MIT License
354 stars 50 forks source link

Validations firing invalid erros #39

Closed awleao closed 11 years ago

awleao commented 11 years ago

I've noticed that every time I execute a save or update operation the framework fires all validations, including uniqueness, but the uniqueness validation consider all records that already are on the database including the record which I am updating, so when I update a record and don't change the property with uniqueness validation it will fire a 'already_exists' message.. I thought I could solve it by adding a filter to ignore the record I am editing something like where field = value and id <> this.id where this.id is related to the id of the current record. Unfortunately I couldn't do it by nesting ARWhereStatements, but I think you could. Check this link with my proposal code https://github.com/awleao/iActiveRecord-Uniqueness

AlexDenisov commented 11 years ago

Thank you for contribution. I've got your point and it makes sense :+1: Looks like I've implemented this 'feature'. 3a2410546674c4ab5f15a41df3e4e4e8541f9a45

AlexDenisov commented 11 years ago

BTW, Pull Requests are welcome.