Jane1234567 / sqlitepersistentobjects

Automatically exported from code.google.com/p/sqlitepersistentobjects
0 stars 0 forks source link

Nil field of SQLitePersistentObject subclass causes NSInvalidArgumentException #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a class WidgetPart that extends SQLitePersistentObject.
2. Create a class Widget that has a property of type WidgetPart.
3. Save a Widget instance with a nil value for the WidgetPart property.
4. [Widget allObjects]

What is the expected output? What do you see instead?

Expected result is an array with a Widget object containing a nil value for the 
WidgetPart 
property.

Actual result is a runtime exception:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '*** 
+[NSString stringWithUTF8String:]: NULL cString'

What version of the product are you using? On what operating system?

URL: http://sqlitepersistentobjects.googlecode.com/svn/trunk
Repository Root: http://sqlitepersistentobjects.googlecode.com/svn
Repository UUID: e86f48c2-4f55-0410-860d-1fbeb81bd84d
Revision: 28

Please provide any additional information below.

Workaround: do a check for null at SQLitePersistentObject.m around line 238:

                        if ([propClass isSubclassOfClass:[SQLitePersistentObject class]])
                        {
                            const char *keyCStr = (const char 
*)sqlite3_column_text(statement, i);
                            if (keyCStr) {
                                NSString *objMemoryMapKey = [NSString 
stringWithUTF8String:keyCStr];
                                                                // and so on
                            }
                            else {
                                [oneItem setValue:nil forKey:propName];
                            }
                        }

Original issue reported on code.google.com by paule...@gmail.com on 13 Jan 2009 at 5:34

GoogleCodeExporter commented 8 years ago
Fixed in r45, thanks Jeff!

Original comment by paule...@gmail.com on 19 Jan 2009 at 5:40

GoogleCodeExporter commented 8 years ago
Cool, thanks for letting me know.

Original comment by jeff.lam...@gmail.com on 19 Feb 2009 at 1:16