Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FCModel.m unique key generation fail #151

Open
Paberu85 opened this issue Mar 13, 2018 · 1 comment
Open

FCModel.m unique key generation fail #151

Paberu85 opened this issue Mar 13, 2018 · 1 comment

Comments

@Paberu85
Copy link

Paberu85 commented Mar 13, 2018

For the while and do...while loops, continue statement causes the program control pass to the conditional test - 'conflict' which is initialized to NO and never changed elsewhere.

                    BOOL conflict = NO;
                    int attempts = 0;
                    do {
                        attempts++;
                        NSAssert1(attempts < 100, @"FCModel subclass %@ is not returning usable, unique values from primaryKeyValueForNewInstance", NSStringFromClass(self.class));
                        
                        id newKeyValue = [self.class primaryKeyValueForNewInstance];
                        if ([self.class instanceFromDatabaseWithPrimaryKey:newKeyValue]) continue; // already exists in database
                        [self setValue:newKeyValue forKey:key];
                    } while (conflict);
@Paberu85
Copy link
Author

Paberu85 commented Feb 12, 2019

As repo is alive and I see you'r ignoring this bug from commit to commit, try running this peace of code, maybe that will convince you to fix it and save anyone else from hassle of finding out why app crashes in production environment due to sqlite unique pk constraint with large amount of records.

BOOL conflict = NO;
do {
    continue;
} while (conflict);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant