@powersync/common 1.22.0 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -390,13 +390,13 @@ export class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
390
390
|
if (writeCheckpoint) {
|
|
391
391
|
const check = await tx.execute(`SELECT 1 FROM ${PSInternalTable.CRUD} LIMIT 1`);
|
|
392
392
|
if (!check.rows?.length) {
|
|
393
|
-
await tx.execute(`UPDATE ${PSInternalTable.BUCKETS} SET target_op = ? WHERE name='$local'`, [
|
|
393
|
+
await tx.execute(`UPDATE ${PSInternalTable.BUCKETS} SET target_op = CAST(? as INTEGER) WHERE name='$local'`, [
|
|
394
394
|
writeCheckpoint
|
|
395
395
|
]);
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
else {
|
|
399
|
-
await tx.execute(`UPDATE ${PSInternalTable.BUCKETS} SET target_op = ? WHERE name='$local'`, [
|
|
399
|
+
await tx.execute(`UPDATE ${PSInternalTable.BUCKETS} SET target_op = CAST(? as INTEGER) WHERE name='$local'`, [
|
|
400
400
|
this.bucketStorageAdapter.getMaxOpId()
|
|
401
401
|
]);
|
|
402
402
|
}
|
|
@@ -63,7 +63,7 @@ export class SqliteBucketStorage extends BaseObserver {
|
|
|
63
63
|
*/
|
|
64
64
|
startSession() { }
|
|
65
65
|
async getBucketStates() {
|
|
66
|
-
const result = await this.db.getAll(
|
|
66
|
+
const result = await this.db.getAll("SELECT name as bucket, cast(last_op as TEXT) as op_id FROM ps_buckets WHERE pending_delete = 0 AND name != '$local'");
|
|
67
67
|
return result;
|
|
68
68
|
}
|
|
69
69
|
async saveSyncData(batch) {
|
|
@@ -204,9 +204,7 @@ export class SqliteBucketStorage extends BaseObserver {
|
|
|
204
204
|
this.compactCounter = 0;
|
|
205
205
|
}
|
|
206
206
|
async updateLocalTarget(cb) {
|
|
207
|
-
const rs1 = await this.db.getAll("SELECT target_op FROM ps_buckets WHERE name = '$local' AND target_op = ?", [
|
|
208
|
-
MAX_OP_ID
|
|
209
|
-
]);
|
|
207
|
+
const rs1 = await this.db.getAll("SELECT target_op FROM ps_buckets WHERE name = '$local' AND target_op = CAST(? as INTEGER)", [MAX_OP_ID]);
|
|
210
208
|
if (!rs1.length) {
|
|
211
209
|
// Nothing to update
|
|
212
210
|
return false;
|
package/lib/db/schema/Schema.js
CHANGED
|
@@ -11,6 +11,16 @@ export class Schema {
|
|
|
11
11
|
tables;
|
|
12
12
|
constructor(tables) {
|
|
13
13
|
if (Array.isArray(tables)) {
|
|
14
|
+
/*
|
|
15
|
+
We need to validate that the tables have a name here because a user could pass in an array
|
|
16
|
+
of Tables that don't have a name because they are using the V2 syntax.
|
|
17
|
+
Therefore, 'convertToClassicTables' won't be called on the tables resulting in a runtime error.
|
|
18
|
+
*/
|
|
19
|
+
for (const table of tables) {
|
|
20
|
+
if (table.name === '') {
|
|
21
|
+
throw new Error("It appears you are trying to create a new Schema with an array instead of an object. Passing in an object instead of an array into 'new Schema()' may resolve your issue.");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
14
24
|
this.tables = tables;
|
|
15
25
|
}
|
|
16
26
|
else {
|