PowerSync 1.0.0
-
Improved the stability of watched queries. Watched queries were previously susceptible to runtime crashes if an exception was thrown in the update stream. Errors are now gracefully handled.
-
Deprecated
PowerSyncCredentialsuserIdfield. This value is not used by the PowerSync service. -
Added
readLockandwriteLockAPIs. These methods allow obtaining a SQLite connection context without starting a transaction. -
Removed references to the PowerSync Kotlin SDK from all public API protocols. Dedicated Swift protocols are now defined. These protocols align better with Swift primitives. See the
BRAKING CHANGESsection for more details. Updated protocols include:ConnectionContext- The context provided byreadLockandwriteLockTransaction- The context provided byreadTransactionandwriteTransactionCrudBatch- Response fromgetCrudBatchCrudTransactionResponse fromgetNextCrudTransactionCrudEntry- Crud entries forCrudBatchandCrudTransactionUpdateType- Operation type forCrudEntrysSqlCursor- Cursor used to map SQLite results to typed result setsJsonParam- JSON parameters used to declare client parameters in theconnectmethodJsonValue- Individual JSON field types forJsonParam
-
Database and transaction/lock level query
executemethods now have@discardableResultannotation. -
Query methods'
parameterstyping has been updated to[Any?]from[Any]. This makes passingnilor optional values to queries easier. -
AttachmentContext,AttachmentQueue,AttachmentServiceandSyncingServiceare are now explicitly declared asopenclasses, allowing them to be subclassed outside the defining module.
BREAKING CHANGES:
- Completing CRUD transactions or CRUD batches, in the
PowerSyncBackendConnectoruploadDatahandler, now has a simpler invocation.
- _ = try await transaction.complete.invoke(p1: nil)
+ try await transaction.complete()indexbasedSqlCursorgetters now throw if the query result column value isnil. This is now consistent with the behaviour of named column getter operations. NewgetXxxxxOptional(index: index)methods are available if the query result value could benil.
let results = try transaction.getAll(
sql: "SELECT * FROM my_table",
parameters: [id]
) { cursor in
- cursor.getString(index: 0)!
+ cursor.getStringOptional(index: 0)
+ // OR
+ // try cursor.getString(index: 0) // if the value should be required
}SqlCursorgetters now directly return Swift types.getLonghas been replaced withgetInt64.
let results = try transaction.getAll(
sql: "SELECT * FROM my_table",
parameters: [id]
) { cursor in
- cursor.getBoolean(index: 0)?.boolValue,
+ cursor.getBooleanOptional(index: 0),
- cursor.getLong(index: 0)?.int64Value,
+ cursor.getInt64Optional(index: 0)
+ // OR
+ // try cursor.getInt64(index: 0) // if the value should be required
}- Client parameters now need to be specified with strictly typed
JsonValueenums.
try await database.connect(
connector: PowerSyncBackendConnector(),
params: [
- "foo": "bar"
+ "foo": .string("bar")
]
)SyncStatusvalues now use Swift primitives for status attributes.lastSyncedAtnow is ofDatetype.
- let lastTime: Date? = db.currentStatus.lastSyncedAt.map {
- Date(timeIntervalSince1970: TimeInterval($0.epochSeconds))
- }
+ let time: Date? = db.currentStatus.lastSyncedAtcrudThrottleMsandretryDelayMsin theconnectmethod have been updated tocrudThrottleandretryDelaywhich are now of typeTimeInterval. Previously the parameters were specified in milliseconds, theTimeIntervaltyping now requires values to be specified in seconds.
try await database.connect(
connector: PowerSyncBackendConnector(),
- crudThrottleMs: 1000,
- retryDelayMs: 5000,
+ crudThrottle: 1,
+ retryDelay: 5,
params: [
"foo": .string("bar"),
]
)throttleMsin the watched queryWatchOptionshas been updated tothrottlewhich is now of typeTimeInterval. Previously the parameters were specified in milliseconds, theTimeIntervaltyping now requires values to be specified in seconds.
let stream = try database.watch(
options: WatchOptions(
sql: "SELECT name FROM users ORDER BY id",
- throttleMs: 1000,
+ throttle: 1,
mapper: { cursor in
try cursor.getString(index: 0)
}
))