Issues using sqlpo

5 views
Skip to first unread message

Fabien Penso

unread,
Mar 13, 2009, 8:14:30 PM3/13/09
to sqlitepersiste...@googlegroups.com
Hi everyone,

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 ?

Fabien Penso

unread,
Mar 13, 2009, 8:53:00 PM3/13/09
to sqlitepersiste...@googlegroups.com
On Sat, Mar 14, 2009 at 1:14 AM, Fabien Penso <fabie...@gmail.com> wrote:

> 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.

Joachim Dagerot

unread,
Mar 14, 2009, 4:27:10 AM3/14/09
to sqlitepersiste...@googlegroups.com

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.

I don't recall if this was decided or if it's been implemented in the code yet. But according to your 'bug' it seems like it's in the code by now. I suspect that the documentation is lagging otherwise you wouldn't end up in this situation.

Fabien Penso

unread,
Mar 14, 2009, 6:00:41 AM3/14/09
to sqlitepersiste...@googlegroups.com
On Sat, Mar 14, 2009 at 9:27 AM, Joachim Dagerot <j...@dagerot.com> wrote:

> 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.

Scott Lyons

unread,
Mar 14, 2009, 11:01:40 AM3/14/09
to sqlitepersiste...@googlegroups.com, sqlitepersiste...@googlegroups.com
The aforementioned '_' character for use in transient properties has
not been implemented, as a consensus was not reached.

In regards to your property name problems, SQLPO automatically
translates the names to underscore separated names to prevent column
name collision.

Fabien Penso

unread,
Mar 14, 2009, 11:17:36 AM3/14/09
to sqlitepersiste...@googlegroups.com
On Sat, Mar 14, 2009 at 4:01 PM, Scott Lyons <scott...@gmail.com> wrote:

> 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...

Reply all
Reply to author
Forward
0 new messages