Skip to content

Commit b21595a

Browse files
gh-action-runnergh-action-runner
authored andcommitted
Squashed 'apollo-ios/' changes from c5a0eef72..b471acffb
b471acffb Improvement: Add result code to SQLiteError (#755) 33108ecc2 Update roadmap last updated date and milestones git-subtree-dir: apollo-ios git-subtree-split: b471acffb09bc50b8fa475bf4e1cefc8d7511ae6
1 parent 79f47bf commit b21595a

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

ROADMAP.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🔮 Apollo iOS Roadmap
22

3-
**Last updated: 2025-09-03**
3+
**Last updated: 2025-09-16**
44

55
For up to date release notes, refer to the project's [Changelog](https://github.com/apollographql/apollo-ios/blob/main/CHANGELOG.md).
66

@@ -30,7 +30,7 @@ Beta Release Milestones:
3030

3131
* ✅ Apollo-iOS
3232
* ✅ ApolloCodegenLib
33-
* 🔲 GraphQLQueryWatcher
33+
* 🔲 Documentation
3434
* 🔲 ApolloWebSocket (Will be released with Apollo-iOS 2.1)
3535

3636
Current RFC for design is available [here](https://github.com/apollographql/apollo-ios/issues/3411)._

Sources/ApolloSQLite/ApolloSQLiteDatabase.swift

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ public final class ApolloSQLiteDatabase: SQLiteDatabase {
3939

4040
private func openConnection() throws {
4141
let flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_URI
42-
if sqlite3_open_v2(dbURL.path, &db, flags, nil) != SQLITE_OK {
43-
throw SQLiteError.open(path: dbURL.path)
42+
let result = sqlite3_open_v2(dbURL.path, &db, flags, nil)
43+
if result != SQLITE_OK {
44+
throw SQLiteError.open(path: dbURL.path, resultCode: result)
4445
}
4546
}
4647

@@ -56,15 +57,16 @@ public final class ApolloSQLiteDatabase: SQLiteDatabase {
5657
private func exec(_ sql: String, errorMessage: @autoclosure () -> String) throws -> Int32 {
5758
let result = sqlite3_exec(db, sql, nil, nil, nil)
5859
if result != SQLITE_OK {
59-
throw SQLiteError.execution(message: "\(errorMessage()): \(sqliteErrorMessage())")
60+
throw SQLiteError.execution(message: "\(errorMessage()): \(sqliteErrorMessage())", resultCode: result)
6061
}
6162
return result
6263
}
6364

6465
private func prepareStatement(_ sql: String, errorMessage: @autoclosure () -> String) throws -> OpaquePointer? {
6566
var stmt: OpaquePointer?
66-
if sqlite3_prepare_v2(db, sql, -1, &stmt, nil) != SQLITE_OK {
67-
throw SQLiteError.prepare(message: "\(errorMessage()): \(sqliteErrorMessage())")
67+
let result = sqlite3_prepare_v2(db, sql, -1, &stmt, nil)
68+
if result != SQLITE_OK {
69+
throw SQLiteError.prepare(message: "\(errorMessage()): \(sqliteErrorMessage())", resultCode: result)
6870
}
6971
return stmt
7072
}
@@ -118,7 +120,7 @@ public final class ApolloSQLiteDatabase: SQLiteDatabase {
118120
rows.append(DatabaseRow(cacheKey: key, storedInfo: record))
119121
} else if result != SQLITE_DONE {
120122
let errorMsg = String(cString: sqlite3_errmsg(db))
121-
throw SQLiteError.step(message: "Failed to step raw row select: \(errorMsg)")
123+
throw SQLiteError.step(message: "Failed to step raw row select: \(errorMsg)", resultCode: result)
122124
}
123125
} while result != SQLITE_DONE
124126

@@ -149,10 +151,11 @@ public final class ApolloSQLiteDatabase: SQLiteDatabase {
149151
for (key, record) in records {
150152
sqlite3_bind_text(stmt, 1, key, -1, SQLITE_TRANSIENT)
151153
sqlite3_bind_text(stmt, 2, record, -1, SQLITE_TRANSIENT)
152-
153-
if sqlite3_step(stmt) != SQLITE_DONE {
154+
155+
let result = sqlite3_step(stmt)
156+
if result != SQLITE_DONE {
154157
rollbackTransaction()
155-
throw SQLiteError.step(message: "Insert/update failed: \(sqliteErrorMessage())")
158+
throw SQLiteError.step(message: "Insert/update failed: \(sqliteErrorMessage())", resultCode: result)
156159
}
157160

158161
sqlite3_reset(stmt)
@@ -175,8 +178,9 @@ public final class ApolloSQLiteDatabase: SQLiteDatabase {
175178
defer { sqlite3_finalize(stmt) }
176179

177180
sqlite3_bind_text(stmt, 1, cacheKey, -1, SQLITE_TRANSIENT)
178-
if sqlite3_step(stmt) != SQLITE_DONE {
179-
throw SQLiteError.step(message: "Delete failed: \(sqliteErrorMessage())")
181+
let result = sqlite3_step(stmt)
182+
if result != SQLITE_DONE {
183+
throw SQLiteError.step(message: "Delete failed: \(sqliteErrorMessage())", resultCode: result)
180184
}
181185
}
182186
}
@@ -191,8 +195,9 @@ public final class ApolloSQLiteDatabase: SQLiteDatabase {
191195
defer { sqlite3_finalize(stmt) }
192196

193197
sqlite3_bind_text(stmt, 1, wildcardPattern, -1, SQLITE_TRANSIENT)
194-
if sqlite3_step(stmt) != SQLITE_DONE {
195-
throw SQLiteError.step(message: "Pattern delete failed: \(sqliteErrorMessage())")
198+
let result = sqlite3_step(stmt)
199+
if result != SQLITE_DONE {
200+
throw SQLiteError.step(message: "Pattern delete failed: \(sqliteErrorMessage())", resultCode: result)
196201
}
197202
}
198203
}

Sources/ApolloSQLite/SQLiteDatabase.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ public struct DatabaseRow {
1414
}
1515

1616
public enum SQLiteError: Error, CustomStringConvertible {
17-
case execution(message: String)
18-
case open(path: String)
19-
case prepare(message: String)
20-
case step(message: String)
17+
case execution(message: String, resultCode: Int32)
18+
case open(path: String, resultCode: Int32)
19+
case prepare(message: String, resultCode: Int32)
20+
case step(message: String, resultCode: Int32)
2121

2222
public var description: String {
2323
switch self {
24-
case .execution(let message):
24+
case .execution(let message, _):
2525
return message
26-
case .open(let path):
26+
case .open(let path, _):
2727
return "Failed to open SQLite database connection at path: \(path)"
28-
case .prepare(let message):
28+
case .prepare(let message, _):
2929
return message
30-
case .step(let message):
30+
case .step(let message, _):
3131
return message
3232
}
3333
}

0 commit comments

Comments
 (0)