I've been trying to use sqlpo for a few hours now, it works on some
cases and not others. I loop in an NSArray to save all the elements I
have in memory,
before saving the pk does not exist, after it exists and the data is
properly saved. The sqlite database is filled up with the proper
datas, a call to a SQL sequence
with findFirstByCriteria with WHERE conditions returns proper result,
but the resulted models once I'm out of the "saving" loop are empty of
datas except for that pk column.
My code is very simple :
#import "SQLitePersistentObject.h"
@interface Theater : SQLitePersistentObject {
NSString *name;
}
@property (nonatomic, readwrite, retain) NSString *name;
#import "NSString-SQLiteColumnName.h"
@implementation Theater
@synthesize name;
...
@end
Any idea where I could look at ?
> I've been trying to use sqlpo for a few hours now, it works on some
> cases and not others. I loop in an NSArray to save all the elements I
> have in memory,
I found the bug. The following returns nil for properties which
include a '_' in their name. I changed
my properties' name and it works fine now.
NSString *colType = [theProps valueForKey:propName]; // line 287 in
file SQLitePersistentObject.m
However even with something than I would have thought would be fast,
it seems pretty slow. Adding such
a big bug scares me a bit using sqlpo now. I'd be happy to have any
feedbacks from productions users
with tables using > 5,000 entries with simple data (no big blob etc).
I'd appreciate performance test to be included in the test so we can
see what to expect (and it would
help your future development for optimizing things making sure it
would get faster and not ... slower).
Too bad it just took me 6 hours to figure this bug out :(
Thanks.
I found the bug. The following returns nil for properties which
include a '_' in their name. I changed
my properties' name and it works fine now.
> I'm following this mailing list briefly and there was a discussion last week
> on how private properties could be named so they didn't end up in the
> database. One of the suggestions was using an underscore as a prefix to the
> name.
My properties do not prefix with _, they where just named like
my_properties
and the code break out of the loop when the line I pasted previously
returns nil.
The error is in NSString-SQLiteColumnName.m, the stringAsSQLColumnName
method returns "my__properties" in such case, and
stringAsPropertyString returns "myProperties".
I guess some unit testing is seriously needed.
> In regards to your property name problems, SQLPO automatically
> translates the names to underscore separated names to prevent column
> name collision.
Scott,
Thanks for your reply but still, there is a bug as properties
including '_' do not work at all, it fails to load all properties (all
the following ones).
Try it...