Skip to content

Commit d7ede36

Browse files
committed
Use ID instead of server ID for updateFromJson queries
While server IDs should work just fine, it is still safer to use the tables' primary keys to refrence existing records.
1 parent ac1175c commit d7ede36

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

libpretixsync/src/main/java/eu/pretix/libpretixsync/sync/CashierSyncAdapter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class CashierSyncAdapter(
7070
name = jsonobj.getString("name"),
7171
pin = if (jsonobj.isNull("pin")) "" else jsonobj.getString("pin"),
7272
userid = jsonobj.getString("userid"),
73-
server_id = jsonobj.getLong("id"),
73+
id = obj.id,
7474
)
7575
}
7676

libpretixsync/src/main/java/eu/pretix/libpretixsync/sync/ItemCategorySyncAdapter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ItemCategorySyncAdapter(
6262
is_addon = jsonobj.optBoolean("is_addon", false),
6363
json_data = jsonobj.toString(),
6464
position = jsonobj.getLong("position"),
65-
server_id = jsonobj.getLong("id"),
65+
id = obj.id,
6666
)
6767
}
6868

libpretixsync/src/main/java/eu/pretix/libpretixsync/sync/ItemSyncAdapter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ItemSyncAdapter(
8484
json_data = jsonobj.toString(),
8585
picture_filename = pictureFilename,
8686
position = jsonobj.getLong("position"),
87-
server_id = jsonobj.getLong("id"),
87+
id = obj.id,
8888
)
8989
}
9090

libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/Cashier.sq

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ SET
4848
name = ?,
4949
pin = ?,
5050
userid = ?
51-
WHERE server_id = ?;
51+
WHERE id = ?;

libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/Item.sq

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ SET
6666
json_data = ?,
6767
picture_filename = ?,
6868
position = ?
69-
WHERE server_id = ?;
69+
WHERE id = ?;

libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/ItemCategory.sq

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ SET
4646
is_addon = ?,
4747
json_data = ?,
4848
"position" = ?
49-
WHERE server_id = ?;
49+
WHERE id = ?;

0 commit comments

Comments
 (0)