AlexDenisov / iActiveRecord

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

Attempt to mutate immutable object with appendFormat: #50

Open danpe opened 10 years ago

danpe commented 10 years ago

Using the following lines:

    ARLazyFetcher* fetcher = team.users;
    User* asker = [self asker];
    if (asker != nil) {
        [fetcher where:@"'user'.'serverUserId' != %@", asker.serverUserId, nil];
        return fetcher.fetchRecords;
    }

crashed from Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to mutate immutable object with appendFormat:'

on

[fetcher where:@"'user'.'serverUserId' != %@", asker.serverUserId, nil];

AlexDenisov commented 10 years ago

Could you add breakpoint to [fetcher where:... and print description of fetcher.whereStatement? Seems that whereStatement is not a mutable string.

danpe commented 10 years ago

Printed the description:

Printing description of fetcher:
<ARLazyFetcher: 0x1287cc20>
Printing description of fetcher->whereStatement:
"Member"."teamId" = "1"

screenshot 2013-10-20 14 06 13

ghost commented 10 years ago

@AlexDenisov it happens sometimes to me too, mutable objects become immutable. I guess you could secure this by using myObject = [myObject mutableCopy] where you feel like it could go wrong.