Skip to content

Releases: powersync-ja/powersync-swift

PowerSync 1.0.0

02 May 13:52
916211d
Compare
Choose a tag to compare
  • 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 and writeLock 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 by readLock and writeLock
    • Transaction - The context provided by readTransaction and writeTransaction
    • CrudBatch - Response from getCrudBatch
    • CrudTransaction Response from getNextCrudTransaction
    • CrudEntry - Crud entries for CrudBatch and CrudTransaction
    • UpdateType - Operation type for CrudEntrys
    • SqlCursor - Cursor used to map SQLite results to typed result sets
    • JsonParam - JSON parameters used to declare client parameters in the connect method
    • JsonValue - Individual JSON field types for JsonParam
  • 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 passing nil or optional values to queries easier.

  • AttachmentContext, AttachmentQueue, AttachmentService and SyncingService are are now explicitly declared as open 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 based SqlCursor getters now throw if the query result column value is nil. This is now consistent with the behaviour of named column getter operations. New getXxxxxOptional(index: index) methods are available if the query result value could be nil.
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 with getInt64.
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 of Date type.
- let lastTime: Date? = db.currentStatus.lastSyncedAt.map {
-     Date(timeIntervalSince1970: TimeInterval($0.epochSeconds))
- }
+ let time: Date? = db.currentStatus.lastSyncedAt
  • crudThrottleMs and retryDelayMs in the connect method have been updated to crudThrottle and retryDelay which are now of type TimeInterval. Previously the parameters were specified in milliseconds, the TimeInterval 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 query WatchOptions has been updated to throttle which is now of type TimeInterval. Previously the parameters were specified in milliseconds, the TimeInterval 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

24 Apr 17:03
bb8f190
Compare
Choose a tag to compare
Pre-release
  • Update powersync-kotlin dependency to version 1.0.0-BETA32, which includes:
    • Removed unnecessary User-Id header from internal PowerSync service requests.
    • Fix getNextCrudTransaction() only returning a single item.

PowerSync 1.0.0-Beta.12

23 Apr 09:38
df4c602
Compare
Choose a tag to compare
Pre-release
  • Added attachment sync helpers
  • Added support for cancellations in watched queries

PowerSync v1.0.0-Beta.11

15 Apr 18:23
e20880a
Compare
Choose a tag to compare
Pre-release

Fix deadlock when calling connect() immediately after opening database.

PowerSync v1.0.0-Beta.10

15 Apr 11:41
9333846
Compare
Choose a tag to compare
Pre-release
  • 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 on PowerSyncDatabaseProtocol
  • Update powersync-kotlin dependency to version 1.0.0-BETA29, which fixes these issues:
    • Fix potential race condition between jobs in connect() and disconnect().
    • Fix race condition causing data received during uploads not to be applied.
    • Fixed issue where automatic driver migrations would fail with the error:
Sqlite operation failure database is locked attempted to run migration and failed. closing connection

PowerSync v1.0.0-Beta.9

27 Mar 15:10
3209c98
Compare
Choose a tag to compare
Pre-release
  • 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

06 Mar 13:58
9cb306f
Compare
Choose a tag to compare
Pre-release
  • 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

18 Feb 13:08
abca0c9
Compare
Choose a tag to compare
Pre-release
  • Fixed an issue where throwing exceptions in the query mapper could cause a runtime crash.
  • Internally improved type casting.

PowerSync v1.0.0-Beta.6

13 Feb 08:26
f50f8dd
Compare
Choose a tag to compare
Pre-release
  • BREAKING CHANGE: watch queries are now throwable and therefore will need to be accompanied by a try e.g.
try database.watch()
  • BREAKING CHANGE: transaction functions are now throwable and therefore will need to be accompanied by a try e.g.
try await database.writeTransaction { transaction in
  try transaction.execute(...)
}
  • Allow execute errors to be handled
  • userId is now set to nil by default and therefore it is no longer required to be set to nil when instantiating PowerSyncCredentials and can therefore be left out.

PowerSync v1.0.0-Beta.5

11 Feb 07:06
72dd7e1
Compare
Choose a tag to compare
Pre-release
  • Implement improvements to errors originating in Kotlin so that they can be handled in Swift

  • Improve __fetchCredentialsto log the error but not cause an app crash on error