Skip to content

Commit db76b6d

Browse files
authored
Merge pull request #189 from powersync-ja/schema-options-name
Rename `oldData` in CRUD entries to `previousValues`
2 parents c103c0f + 26f0957 commit db76b6d

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Changelog
22

3-
## unreleased
3+
## 1.1.0
44

5-
* Add `trackPreviousValues` option on `Table` which sets `CrudEntry.oldData` to previous values on updates.
5+
* Add `trackPreviousValues` option on `Table` which sets `CrudEntry.previousValues` to previous values on updates.
66
* Add `trackMetadata` option on `Table` which adds a `_metadata` column that can be used for updates.
77
The configured metadata is available through `CrudEntry.metadata`.
88
* Add `ignoreEmptyUpdates` option which skips creating CRUD entries for updates that don't change any values.

core/src/commonIntegrationTest/kotlin/com/powersync/CrudTest.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CrudTest {
3333
database.execute("UPDATE lists SET name = ?", listOf("new name"))
3434

3535
val batch = database.getNextCrudTransaction()
36-
batch!!.crud[0].oldData shouldBe mapOf("name" to "entry", "content" to "content")
36+
batch!!.crud[0].previousValues shouldBe mapOf("name" to "entry", "content" to "content")
3737
}
3838

3939
@Test
@@ -54,7 +54,7 @@ class CrudTest {
5454
database.execute("UPDATE lists SET name = ?, content = ?", listOf("new name", "new content"))
5555

5656
val batch = database.getNextCrudTransaction()
57-
batch!!.crud[0].oldData shouldBe mapOf("name" to "entry")
57+
batch!!.crud[0].previousValues shouldBe mapOf("name" to "entry")
5858
}
5959

6060
@Test
@@ -75,7 +75,7 @@ class CrudTest {
7575
database.execute("UPDATE lists SET name = ?", listOf("new name"))
7676

7777
val batch = database.getNextCrudTransaction()
78-
batch!!.crud[0].oldData shouldBe mapOf("name" to "entry")
78+
batch!!.crud[0].previousValues shouldBe mapOf("name" to "entry")
7979
}
8080

8181
@Test

core/src/commonMain/kotlin/com/powersync/db/crud/CrudEntry.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public data class CrudEntry(
6464
* These values can be tracked for `UPDATE` statements when [Table.trackPreviousValues] is
6565
* enabled.
6666
*/
67-
val oldData: Map<String, String?>? = null,
67+
val previousValues: Map<String, String?>? = null,
6868
) {
6969
public companion object {
7070
public fun fromRow(row: CrudRow): CrudEntry {
@@ -80,7 +80,7 @@ public data class CrudEntry(
8080
table = data["type"]!!.jsonPrimitive.content,
8181
transactionId = row.txId,
8282
metadata = data["metadata"]?.jsonPrimitive?.content,
83-
oldData =
83+
previousValues =
8484
data["old"]?.jsonObject?.mapValues { (_, value) ->
8585
value.jsonPrimitive.contentOrNull
8686
},

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public data class Table(
4343
*/
4444
val trackMetadata: Boolean = false,
4545
/**
46-
* When set to a non-null value, track old values of columns for [CrudEntry.oldData].
46+
* When set to a non-null value, track old values of columns for [CrudEntry.previousValue].
4747
*
4848
* See [TrackPreviousValuesOptions] for details.
4949
*/
@@ -219,7 +219,7 @@ public data class Table(
219219
}
220220

221221
/**
222-
* Options to include old values in [CrudEntry.oldData] for update statements.
222+
* Options to include old values in [CrudEntry.previousValue] for update statements.
223223
*
224224
* These options are enabled by passing them to a non-local [Table] constructor.
225225
*/
@@ -228,7 +228,7 @@ public data class TrackPreviousValuesOptions(
228228
* A filter of column names for which updates should be tracked.
229229
*
230230
* When set to a non-null value, columns not included in this list will not appear in
231-
* [CrudEntry.oldData]. By default, all columns are included.
231+
* [CrudEntry.previousValues]. By default, all columns are included.
232232
*/
233233
val columnFilter: List<String>? = null,
234234
/**

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ development=true
1717
RELEASE_SIGNING_ENABLED=true
1818
# Library config
1919
GROUP=com.powersync
20-
LIBRARY_VERSION=1.0.1
20+
LIBRARY_VERSION=1.1.0
2121
# The Swift KMM bridge artifacts are published to SPM via a unique tag version
2222
# The version is the same as the LIBRARY_VERSION, but with a suffix of +SWIFT
2323
# Please update this when updating the LIBRARY_VERSION
24-
SWIFT_LIBRARY_VERSION=1.0.1+SWIFT
24+
SWIFT_LIBRARY_VERSION=1.1.0+SWIFT
2525
GITHUB_REPO=https://github.com/powersync-ja/powersync-kotlin.git
2626
# POM
2727
POM_URL=https://github.com/powersync-ja/powersync-kotlin/

0 commit comments

Comments
 (0)