@powersync/common 1.22.0 → 1.22.2

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('SELECT name as bucket, cast(last_op as TEXT) as op_id FROM ps_buckets WHERE pending_delete = 0');
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;
@@ -12,7 +12,7 @@ export type BaseColumnType<T extends number | string | null> = {
12
12
  };
13
13
  export type ColumnsType = Record<string, BaseColumnType<any>>;
14
14
  export type ExtractColumnValueType<T extends BaseColumnType<any>> = T extends BaseColumnType<infer R> ? R : unknown;
15
- export declare const MAX_AMOUNT_OF_COLUMNS = 63;
15
+ export declare const MAX_AMOUNT_OF_COLUMNS = 1999;
16
16
  export declare const column: {
17
17
  text: BaseColumnType<string | null>;
18
18
  integer: BaseColumnType<number | null>;
@@ -14,9 +14,9 @@ const integer = {
14
14
  const real = {
15
15
  type: ColumnType.REAL
16
16
  };
17
- // There is maximum of 127 arguments for any function in SQLite. Currently we use json_object which uses 1 arg per key (column name)
18
- // and one per value, which limits it to 63 arguments.
19
- export const MAX_AMOUNT_OF_COLUMNS = 63;
17
+ // powersync-sqlite-core limits the number of column per table to 1999, due to internal SQLite limits.
18
+ // In earlier versions this was limited to 63.
19
+ export const MAX_AMOUNT_OF_COLUMNS = 1999;
20
20
  export const column = {
21
21
  text,
22
22
  integer,
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/common",
3
- "version": "1.22.0",
3
+ "version": "1.22.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -59,7 +59,7 @@
59
59
  "scripts": {
60
60
  "build": "tsc -b && rollup -c rollup.config.mjs",
61
61
  "build:prod": "tsc -b --sourceMap false && rollup -c rollup.config.mjs --sourceMap false",
62
- "clean": "rm -rf lib dist tsconfig.tsbuildinfo",
62
+ "clean": "rm -rf lib dist tsconfig.tsbuildinfo node_modules",
63
63
  "test": "vitest"
64
64
  }
65
65
  }