FCModel icon indicating copy to clipboard operation
FCModel copied to clipboard

FCModel.m unique key generation fail

Open Paberu85 opened this issue 7 years ago • 1 comments

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 avatar Mar 13 '18 12:03 Paberu85

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);

Paberu85 avatar Feb 12 '19 12:02 Paberu85