Skip to content

Commit 12832a9

Browse files
committed
AI feedback
1 parent 855e82c commit 12832a9

4 files changed

Lines changed: 44 additions & 15 deletions

File tree

Sources/PowerSyncGRDB/Connections/AllWritesObserver.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import GRDB
22

33
class AllWritesObserver: TransactionObserver {
44
private(set) var committedTables: Set<String> = []
5-
private var uncomittedTables: Set<String> = []
5+
private var uncommittedTables: Set<String> = []
66

77
var databaseEventObservationStrategy: DatabaseEventObservationStrategy {
8-
var strategy = DatabaseEventObservationStrategy.default
8+
var strategy: DatabaseEventObservationStrategy = DatabaseEventObservationStrategy.default
99
// Don't filter on database event kind, so that we are
1010
// notified of changes performed through the SQLite C API:
1111
strategy.requiresDatabaseEventKind = false
@@ -18,15 +18,15 @@ class AllWritesObserver: TransactionObserver {
1818
}
1919

2020
func databaseDidChange(with event: DatabaseEvent) {
21-
uncomittedTables.insert(event.tableName)
21+
uncommittedTables.insert(event.tableName)
2222
}
2323

2424
func databaseDidCommit(_ db: GRDB.Database) {
25-
committedTables.formUnion(uncomittedTables)
26-
uncomittedTables.removeAll()
25+
committedTables.formUnion(uncommittedTables)
26+
uncommittedTables.removeAll()
2727
}
2828

2929
func databaseDidRollback(_ db: GRDB.Database) {
30-
uncomittedTables.removeAll()
30+
uncommittedTables.removeAll()
3131
}
3232
}

Sources/PowerSyncGRDB/Connections/GRDBConnectionLease.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extension PowerSync.PowerSyncDataType: DatabaseValueConvertible {
4949
}
5050

5151
public static func fromDatabaseValue(_ dbValue: GRDB.DatabaseValue) -> PowerSync.PowerSyncDataType? {
52+
// Unused, we only need databaseValue to pass PowerSyncDataType as StatementParameters
5253
nil
5354
}
5455
}

Sources/PowerSyncGRDB/Connections/RowIterator.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,43 +47,43 @@ struct RowSqlCursor: PowerSync.SqlCursor {
4747
}
4848

4949
public func getBooleanOptional(index: Int) -> Bool? {
50-
return row.self[index]
50+
return row[index]
5151
}
5252

5353
public func getDouble(index: Int) throws(PowerSync.SqlCursorError) -> Double {
5454
try checkNotNull(index: index)
55-
return row.self[index]
55+
return row[index]
5656
}
5757

5858
public func getDoubleOptional(index: Int) -> Double? {
59-
return row.self[index]
59+
return row[index]
6060
}
6161

6262
public func getInt(index: Int) throws(PowerSync.SqlCursorError) -> Int {
6363
try checkNotNull(index: index)
64-
return row.self[index]
64+
return row[index]
6565
}
6666

6767
public func getIntOptional(index: Int) -> Int? {
68-
return row.self[index]
68+
return row[index]
6969
}
7070

7171
public func getInt64(index: Int) throws(PowerSync.SqlCursorError) -> Int64 {
7272
try self.checkNotNull(index: index)
73-
return row.self[index]
73+
return row[index]
7474
}
7575

7676
public func getInt64Optional(index: Int) -> Int64? {
77-
return row.self[index]
77+
return row[index]
7878
}
7979

8080
public func getString(index: Int) throws(PowerSync.SqlCursorError) -> String {
8181
try self.checkNotNull(index: index)
82-
return row.self[index]
82+
return row[index]
8383
}
8484

8585
public func getStringOptional(index: Int) -> String? {
86-
return row.self[index]
86+
return row[index]
8787
}
8888

8989
public var columnCount: Int {

Tests/PowerSyncGRDBTests/BasicTest.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,34 @@ final class GRDBTests: XCTestCase {
452452

453453
XCTAssert(warningIndex! >= 0)
454454
}
455+
456+
func testBindValues() async throws {
457+
try await database.readLock { lease in
458+
try lease.get(
459+
sql: "SELECT ?, ?, ?, ?, ?, ?, typeof(?), typeof(?)",
460+
parameters: [
461+
nil,
462+
false,
463+
Int32(32),
464+
Int64(64),
465+
3.14,
466+
"hello",
467+
Data(),
468+
Data([1, 2, 3])
469+
],
470+
mapper: { cursor in
471+
XCTAssertEqual(cursor.getStringOptional(index: 0), nil)
472+
XCTAssertEqual(try cursor.getBoolean(index: 1), false)
473+
XCTAssertEqual(try cursor.getInt(index: 2), 32)
474+
XCTAssertEqual(try cursor.getInt(index: 3), 64)
475+
XCTAssertEqual(try cursor.getDouble(index: 4), 3.14)
476+
XCTAssertEqual(try cursor.getString(index: 5), "hello")
477+
XCTAssertEqual(try cursor.getString(index: 6), "blob")
478+
XCTAssertEqual(try cursor.getString(index: 7), "blob")
479+
}
480+
)
481+
}
482+
}
455483
}
456484

457485
final class TestLogWriterAdapter: LogWriterProtocol,

0 commit comments

Comments
 (0)