Skip to content

Commit d595c30

Browse files
committed
format
1 parent a339d66 commit d595c30

14 files changed

Lines changed: 114 additions & 44 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 1.13.0 (unreleased)
44

5-
- __Potentially breaking change__: Aligning with Kotlin and Androidx multiplatform libraries, this
5+
- __Breaking change__: Aligning with Kotlin and Androidx multiplatform libraries, this
66
release removes support for `x86_64` Apple targets (`iosX64()`, `macosX64()`, `tvosX64()` and `watchosX64()`).
77
- Fix sync status to make `syncStreams` return null when the database is initializing.
88
- Fix errors when subscribing to Sync Streams with object or array parameters.

common/src/commonIntegrationTest/kotlin/com/powersync/AttachmentsTest.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class AttachmentsTest {
103103
remoteStorage = remote,
104104
attachmentsDirectory = getAttachmentsDir(),
105105
watchAttachments = { watchAttachments(database) },
106-
/**
106+
/*
107107
* Sets the cache limit to zero for this test. Archived records will
108108
* immediately be deleted.
109109
*/
@@ -141,7 +141,7 @@ class AttachmentsTest {
141141
var attachmentRecord = attachmentQuery.awaitItem().first()
142142
attachmentRecord shouldNotBe null
143143

144-
/**
144+
/*
145145
* The timing of the watched query resolving might differ slightly.
146146
* We might get a watched query result where the attachment is QUEUED_DOWNLOAD
147147
* or we could get the result once it has been DOWNLOADED.
@@ -211,7 +211,7 @@ class AttachmentsTest {
211211
remoteStorage = remote,
212212
attachmentsDirectory = getAttachmentsDir(),
213213
watchAttachments = { watchAttachments(database) },
214-
/**
214+
/*
215215
* Sets the cache limit to zero for this test. Archived records will
216216
* immediately be deleted.
217217
*/
@@ -320,7 +320,7 @@ class AttachmentsTest {
320320
remoteStorage = remote,
321321
attachmentsDirectory = getAttachmentsDir(),
322322
watchAttachments = { watchAttachments(database) },
323-
/**
323+
/*
324324
* Sets the cache limit to zero for this test. Archived records will
325325
* immediately be deleted.
326326
*/
@@ -423,9 +423,7 @@ class AttachmentsTest {
423423
remoteStorage = remote,
424424
attachmentsDirectory = getAttachmentsDir(),
425425
watchAttachments = { watchAttachments(database) },
426-
/**
427-
* Keep some items in the cache
428-
*/
426+
// Keep some items in the cache
429427
archivedCacheLimit = 10,
430428
logger = logger,
431429
)
@@ -460,7 +458,7 @@ class AttachmentsTest {
460458
var attachmentRecord = attachmentQuery.awaitItem().first()
461459
attachmentRecord shouldNotBe null
462460

463-
/**
461+
/*
464462
* The timing of the watched query resolving might differ slightly.
465463
* We might get a watched query result where the attachment is QUEUED_DOWNLOAD
466464
* or we could get the result once it has been DOWNLOADED.

common/src/commonMain/kotlin/com/powersync/attachments/AttachmentQueue.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,13 @@ public open class AttachmentQueue(
323323
@Throws(PowerSyncException::class, CancellationException::class)
324324
public open suspend fun processWatchedAttachments(items: List<WatchedAttachmentItem>): Unit =
325325
runWrapped {
326-
/**
326+
/*
327327
* Use a lock here to prevent conflicting state updates.
328328
*/
329329
attachmentsService.withContext { attachmentsContext ->
330330
logger.v { "processWatchedAttachments($items)" }
331331

332-
/**
332+
/*
333333
* Need to get all the attachments which are tracked in the DB.
334334
* We might need to restore an archived attachment.
335335
*/
@@ -370,7 +370,7 @@ public open class AttachmentQueue(
370370
existingQueueItem.copy(state = AttachmentState.SYNCED),
371371
)
372372
} else {
373-
/**
373+
/*
374374
* The localURI should be set if the record was meant to be downloaded
375375
* and has been synced. If it's missing and hasSynced is false then
376376
* it must be an upload operation.
@@ -389,7 +389,7 @@ public open class AttachmentQueue(
389389
}
390390
}
391391

392-
/**
392+
/*
393393
* Archive any items not specified in the watched items.
394394
* For QUEUED_DELETE or QUEUED_UPLOAD states, archive only if hasSynced is true.
395395
* For other states, archive if the record is not found in the items.
@@ -402,6 +402,7 @@ public open class AttachmentQueue(
402402
when (attachment.state) {
403403
// Archive these record if they have synced
404404
AttachmentState.QUEUED_DELETE, AttachmentState.QUEUED_UPLOAD -> attachment.hasSynced
405+
405406
// Other states, such as QUEUED_DOWNLOAD can be archived if they are not present in watched items
406407
else -> true
407408
}
@@ -446,7 +447,7 @@ public open class AttachmentQueue(
446447
// Write the file to the filesystem.
447448
val fileSize = localStorage.saveFile(localUri, data)
448449

449-
/**
450+
/*
450451
* Starts a write transaction. The attachment record and relevant local relationship
451452
* assignment should happen in the same transaction.
452453
*/
@@ -463,7 +464,7 @@ public open class AttachmentQueue(
463464
metaData = metaData,
464465
)
465466

466-
/**
467+
/*
467468
* Allow consumers to set relationships to this attachment ID.
468469
*/
469470
updateHook.invoke(tx, attachment)
@@ -549,7 +550,7 @@ public open class AttachmentQueue(
549550
}
550551
val exists = localStorage.fileExists(attachment.localUri)
551552
if (
552-
attachment.state == AttachmentState.SYNCED || attachment.state == AttachmentState.QUEUED_UPLOAD && !exists
553+
(attachment.state == AttachmentState.SYNCED || attachment.state == AttachmentState.QUEUED_UPLOAD) && !exists
553554
) {
554555
updates.add(
555556
attachment.copy(

common/src/commonMain/kotlin/com/powersync/attachments/sync/SyncingService.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public open class SyncingService(
9090
.throttle(syncThrottle)
9191
.collect {
9292
attachmentsService.withContext { context ->
93-
/**
93+
/*
9494
* Gets and performs the operations for active attachments which are
9595
* pending download, upload, or delete.
9696
*/
@@ -178,6 +178,7 @@ public open class SyncingService(
178178
}
179179

180180
AttachmentState.SYNCED -> {}
181+
181182
AttachmentState.ARCHIVED -> {}
182183
}
183184
}

common/src/commonMain/kotlin/com/powersync/db/crud/SerializedRow.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,18 @@ private data class ToTypedEntry(
9797
// Note: Array and object values never appear in a CRUD row (they would be
9898
// represented as strings instead). We also use TypedRows to represent stream
9999
// parameters though, and those can be arrays/objects.
100-
is JsonArray -> map { it.asData() }
101-
is JsonObject -> mapValues { it.value.asData() }
102-
JsonNull -> null
100+
is JsonArray -> {
101+
map { it.asData() }
102+
}
103+
104+
is JsonObject -> {
105+
mapValues { it.value.asData() }
106+
}
107+
108+
JsonNull -> {
109+
null
110+
}
111+
103112
is JsonPrimitive -> {
104113
if (isString) {
105114
content

common/src/commonMain/kotlin/com/powersync/db/driver/ReadPool.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ internal class ReadPool(
6666
val obtainedConnections = mutableListOf<Pair<SQLiteConnection, CompletableDeferred<Unit>>>()
6767

6868
try {
69-
/**
69+
/*
7070
* This attempts to receive (all) the number of available connections.
7171
* This creates a hold for each connection received. This means that subsequent
7272
* receive operations must return unique connections until all the available connections

common/src/commonMain/kotlin/com/powersync/db/internal/ConnectionContext.kt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,30 @@ internal fun SQLiteStatement.bind(parameters: List<Any?>?) {
108108
val index = i + 1
109109

110110
when (parameter) {
111-
is Boolean -> bindBoolean(index, parameter)
112-
is String -> bindText(index, parameter)
113-
is Long -> bindLong(index, parameter)
114-
is Int -> bindLong(index, parameter.toLong())
115-
is Double -> bindDouble(index, parameter)
116-
is ByteArray -> bindBlob(index, parameter)
111+
is Boolean -> {
112+
bindBoolean(index, parameter)
113+
}
114+
115+
is String -> {
116+
bindText(index, parameter)
117+
}
118+
119+
is Long -> {
120+
bindLong(index, parameter)
121+
}
122+
123+
is Int -> {
124+
bindLong(index, parameter.toLong())
125+
}
126+
127+
is Double -> {
128+
bindDouble(index, parameter)
129+
}
130+
131+
is ByteArray -> {
132+
bindBlob(index, parameter)
133+
}
134+
117135
else -> {
118136
if (parameter != null) {
119137
throw IllegalArgumentException("Unsupported parameter type: ${parameter::class}, at index $index")

common/src/commonMain/kotlin/com/powersync/db/internal/PowerSyncVersion.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ internal data class PowerSyncVersion(
77
) : Comparable<PowerSyncVersion> {
88
override fun compareTo(other: PowerSyncVersion): Int =
99
when (val compareMajor = major.compareTo(other.major)) {
10-
0 ->
10+
0 -> {
1111
when (val compareMinor = minor.compareTo(other.minor)) {
1212
0 -> patch.compareTo(other.patch)
1313
else -> compareMinor
1414
}
15-
else -> compareMajor
15+
}
16+
17+
else -> {
18+
compareMajor
19+
}
1620
}
1721

1822
override fun toString(): String = "$major.$minor.$patch"

common/src/commonMain/kotlin/com/powersync/db/schema/RawTable.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,19 @@ internal object PendingStatementSerializer : OnlySerializer<PendingStatement>()
206206
serializer<List<JsonElement>>(),
207207
value.parameters.map { p ->
208208
when (p) {
209-
is PendingStatementParameter.Column ->
209+
is PendingStatementParameter.Column -> {
210210
buildJsonObject {
211211
put("Column", JsonPrimitive(p.name))
212212
}
213-
PendingStatementParameter.Id -> JsonPrimitive("Id")
214-
PendingStatementParameter.Rest -> JsonPrimitive("Rest")
213+
}
214+
215+
PendingStatementParameter.Id -> {
216+
JsonPrimitive("Id")
217+
}
218+
219+
PendingStatementParameter.Rest -> {
220+
JsonPrimitive("Rest")
221+
}
215222
}
216223
},
217224
)

common/src/commonMain/kotlin/com/powersync/db/schema/Table.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public data class Table(
6464
)
6565

6666
init {
67-
/**
67+
/*
6868
* Need to set the column definition for each index column.
6969
* This is required for serialization
7070
*/
@@ -190,7 +190,9 @@ public data class Table(
190190
throw AssertionError("Invalid characters in column name: $name.${column.name}")
191191
}
192192

193-
else -> columnNames.add(column.name)
193+
else -> {
194+
columnNames.add(column.name)
195+
}
194196
}
195197
}
196198

0 commit comments

Comments
 (0)