Skip to content

Commit

Permalink
fix(analytics): iterate sqlite rows with failableNext
Browse files Browse the repository at this point in the history
  • Loading branch information
5d committed Sep 6, 2024
1 parent cb80b91 commit a44a666
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,16 @@ class AnalyticsEventSQLStorage: AnalyticsEventStorage {
ORDER BY timestamp ASC
LIMIT ?
"""
let rows = try dbAdapter.executeQuery(queryStatement, [limit])
let rows = try dbAdapter.executeQuery(queryStatement, [limit]).makeIterator()
var result = [PinpointEvent]()
for element in rows {
if let event = PinpointEvent.convertToEvent(element) {
result.append(event)
do {
while let element = try rows.failableNext() {
if let event = PinpointEvent.convertToEvent(element) {
result.append(event)
}
}
} catch {
Self.log.debug("Failed to iterate event rows from SQLite, error: \(error)")
}
return result
}
Expand Down

0 comments on commit a44a666

Please sign in to comment.