Skip to content

Commit c784392

Browse files
committed
Fix external-change detection in nested DB blocks
1 parent 4ac5ff3 commit c784392

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

FCModel/FCModelDatabase.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ + (void)postChangeNotificationWithChangedFields:(NSSet *)changedFields;
1414
+ (void)dataChangedExternally;
1515
@end
1616

17-
@interface FCModelDatabase ()
17+
@interface FCModelDatabase () {
18+
uint32_t changeCounterBeforeBlock; // ivar instead of local so nested inDatabase calls work without mistakenly invoking dataChangedExternally
19+
}
20+
1821
- (uint32_t)sqliteChangeCount;
1922
- (BOOL)sqliteChangeTrackingIsActive;
2023
@property (nonatomic) int32_t expectedChangeCount;
@@ -133,7 +136,7 @@ - (void)inDatabase:(void (^)(FMDatabase *db))block
133136

134137
FMDatabase *db = self.database;
135138
BOOL hadOpenResultSetsBefore = db.hasOpenResultSets;
136-
uint32_t changeCounterBeforeBlock = [self sqliteChangeCount];
139+
changeCounterBeforeBlock = [self sqliteChangeCount];
137140

138141
block(db);
139142

0 commit comments

Comments
 (0)