Releases: powersync-ja/powersync-swift
PowerSync 1.2.0
- Improved
CrudBatch
andCrudTransaction
complete
function extensions. Developers no longer need to specifynil
as an argument forwriteCheckpoint
when callingCrudBatch.complete
. The basecomplete
functions still accept an optionalwriteCheckpoint
argument if developers use custom write checkpoints.
guard let finalBatch = try await powersync.getCrudBatch(limit: 100) else {
return nil
}
- try await batch.complete(writeCheckpoint: nil)
+ try await batch.complete()
- Fix reported progress around compactions / defrags on the sync service.
- Use version
0.4.0
of the PowerSync core extension, which improves sync performance. - Add a new sync client implementation written in Rust instead of Kotlin. While this client is still
experimental, we intend to make it the default in the future. The main benefit of this client is
faster sync performance, but upcoming features will also require this client. We encourage
interested users to try it out by opting in to experimental APIs and passing options when
connecting:Switching between the clients can be done at any time without compatibility issues. If you run@_spi(PowerSyncExperimental) import PowerSync try await db.connect(connector: connector, options: ConnectOptions( newClientImplementation: true, ))
into issues with the new client, please reach out to us! - In addition to HTTP streams, the Swift SDK also supports fetching sync instructions from the
PowerSync service in a binary format. This requires the new sync client, and can then be enabled
on the sync options:@_spi(PowerSyncExperimental) import PowerSync try await db.connect(connector: connector, options: ConnectOptions( newClientImplementation: true, connectionMethod: .webSocket, ))
PowerSync 1.1.0
- Add sync progress information through
SyncStatusData.downloadProgress
. - Add
trackPreviousValues
option onTable
which setsCrudEntry.previousValues
to previous values on updates. - Add
trackMetadata
option onTable
which adds a_metadata
column that can be used for updates.
The configured metadata is available throughCrudEntry.metadata
. - Add
ignoreEmptyUpdates
option which skips creating CRUD entries for updates that don't change any values.
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
PowerSyncCredentials
userId
field. This value is not used by the PowerSync service. -
Added
readLock
andwriteLock
APIs. 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 CHANGES
section for more details. Updated protocols include:ConnectionContext
- The context provided byreadLock
andwriteLock
Transaction
- The context provided byreadTransaction
andwriteTransaction
CrudBatch
- Response fromgetCrudBatch
CrudTransaction
Response fromgetNextCrudTransaction
CrudEntry
- Crud entries forCrudBatch
andCrudTransaction
UpdateType
- Operation type forCrudEntry
sSqlCursor
- Cursor used to map SQLite results to typed result setsJsonParam
- JSON parameters used to declare client parameters in theconnect
methodJsonValue
- Individual JSON field types forJsonParam
-
Database and transaction/lock level query
execute
methods now have@discardableResult
annotation. -
Query methods'
parameters
typing has been updated to[Any?]
from[Any]
. This makes passingnil
or optional values to queries easier. -
AttachmentContext
,AttachmentQueue
,AttachmentService
andSyncingService
are are now explicitly declared asopen
classes, allowing them to be subclassed outside the defining module.
BREAKING CHANGES:
- Completing CRUD transactions or CRUD batches, in the
PowerSyncBackendConnector
uploadData
handler, now has a simpler invocation.
- _ = try await transaction.complete.invoke(p1: nil)
+ try await transaction.complete()
index
basedSqlCursor
getters 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
}
SqlCursor
getters now directly return Swift types.getLong
has 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
JsonValue
enums.
try await database.connect(
connector: PowerSyncBackendConnector(),
params: [
- "foo": "bar"
+ "foo": .string("bar")
]
)
SyncStatus
values now use Swift primitives for status attributes.lastSyncedAt
now is ofDate
type.
- let lastTime: Date? = db.currentStatus.lastSyncedAt.map {
- Date(timeIntervalSince1970: TimeInterval($0.epochSeconds))
- }
+ let time: Date? = db.currentStatus.lastSyncedAt
crudThrottleMs
andretryDelayMs
in theconnect
method have been updated tocrudThrottle
andretryDelay
which are now of typeTimeInterval
. Previously the parameters were specified in milliseconds, theTimeInterval
typing 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"),
]
)
throttleMs
in the watched queryWatchOptions
has been updated tothrottle
which is now of typeTimeInterval
. Previously the parameters were specified in milliseconds, theTimeInterval
typing 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)
}
))
PowerSync 1.0.0-Beta.13
- Update
powersync-kotlin
dependency to version1.0.0-BETA32
, which includes:- Removed unnecessary
User-Id
header from internal PowerSync service requests. - Fix
getNextCrudTransaction()
only returning a single item.
- Removed unnecessary
PowerSync 1.0.0-Beta.12
- Added attachment sync helpers
- Added support for cancellations in watched queries
PowerSync v1.0.0-Beta.11
Fix deadlock when calling connect()
immediately after opening database.
PowerSync v1.0.0-Beta.10
- Added the ability to specify a custom logging implementation
let db = PowerSyncDatabase(
schema: Schema(
tables: [
Table(
name: "users",
columns: [
.text("name"),
.text("email")
]
)
]
),
logger: DefaultLogger(minSeverity: .debug)
)
- added
.close()
method onPowerSyncDatabaseProtocol
- Update
powersync-kotlin
dependency to version1.0.0-BETA29
, which fixes these issues:- Fix potential race condition between jobs in
connect()
anddisconnect()
. - Fix race condition causing data received during uploads not to be applied.
- Fixed issue where automatic driver migrations would fail with the error:
- Fix potential race condition between jobs in
Sqlite operation failure database is locked attempted to run migration and failed. closing connection
PowerSync v1.0.0-Beta.9
- Update PowerSync SQLite core extension to 0.3.12.
- Added queuing protection and warnings when connecting multiple PowerSync clients to the same database file.
- Improved concurrent SQLite connection support. A single write connection and multiple read connections are used for concurrent read queries.
- Internally improved the linking of SQLite.
- Enabled Full Text Search support.
- Added the ability to update the schema for existing PowerSync clients.
- Fixed bug where local only, insert only and view name overrides were not applied for schema tables.
PowerSync v1.0.0-Beta.8
- Improved watch query internals. Added the ability to throttle watched queries.
- Added support for sync bucket priorities.
- Fixed uploading and downloading sync status indicators.
PowerSync v1.0.0-Beta.7
- Fixed an issue where throwing exceptions in the query
mapper
could cause a runtime crash. - Internally improved type casting.