AlexDenisov / iActiveRecord

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

ARValidatorPresence crashes #66

Open ghost opened 10 years ago

ghost commented 10 years ago

Hello. I am having a problem and I want a fresh look on this. I have some ActiveRecord entities in my application and both the application / specs (using cedar) targets are crashing (randomly - can happen 3 times in a row, can happen once in a week). And that crash is being traced from the calls:

-[ActiveRecord save]
-[ActiveRecord isValid]
+[ARValidator isValidOnSave:]
-[ARValidator isValidOnSave:]
-[ARValidatorPresence validateField:ofRecord]

It happens on random fields, on random classes.

The cause of the crash is [NSObject(NSKeyValueCoding) valueForKey:] I get an EXC_BAD_INSTRUCTION, code is EXC_i386_INVOP, subcode=0x0 on line:

id aValue = [aRecord valueForKey:aField]

from the ARValidatorPresence's validateField:ofRecord:method. It has been bugging me for complete weeks and months and I could not find a solution for it. Do any of you know what could be possibly going on? Also, the database does not initialize if sqlite3_unicode_load() is executed. (Please note that I've also commented that out, may that be the cause?) (Please don't get harsh on me, I've just did my best to make it work.) Also, if I remove validate_presence_of from the entities validation, everything works OK. Also, I've made specs coverage for the iActiveRecord specs, and some of classes like ARColumn or core columns are not fully covered by specs. I would really love to get any directions on this, please let me know if I should provide any additional info, thanks in advance!

AlexDenisov commented 10 years ago

Hi @nemesis-fw, thank you for feedback. Also, I've received email with the similar issue, so I will look at it.

ghost commented 10 years ago

Thank you @AlexDenisov! If I can help you with anything I'd be delighted to.

ghost commented 10 years ago

@AlexDenisov any updates?

neilabdev commented 10 years ago

ghost. Please see: https://github.com/AlexDenisov/iActiveRecord/pull/78

For possible resolution. Its working for me after applying this fix..