Skip to content

Commit 95c91fe

Browse files
author
Alexis Oyama
committed
fix(event): iOS7 was not deleting events
This was due to older sqlite3 version
1 parent af70402 commit 95c91fe

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Leanplum-SDK/Classes/LPEventDataManager.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ + (NSArray *)eventsWithLimit:(NSInteger)limit
9090

9191
+ (void)deleteEventsWithLimit:(NSInteger)limit
9292
{
93-
NSString *query = [NSString stringWithFormat:@"DELETE FROM event ORDER BY rowid "
94-
"LIMIT %ld", (long)limit];
93+
// Used to be 'DELETE FROM event ORDER BY rowid LIMIT x'
94+
// but iOS7 sqlite3 did not compile with SQLITE_ENABLE_UPDATE_DELETE_LIMIT.
95+
// Consider changing it back when we drop iOS7.
96+
NSString *query = [NSString stringWithFormat:@"DELETE FROM event WHERE rowid IN "
97+
"(SELECT rowid FROM event ORDER BY rowid "
98+
"LIMIT %ld);", (long)limit];
9599
[[LPDatabase sharedDatabase] runQuery:query];
96100
}
97101

0 commit comments

Comments
 (0)