@syncular/server 0.13.0 → 0.15.0

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.
@@ -223,13 +223,9 @@ export function upsertSql(table, dialect) {
223
223
  const names = tableColumnNames(table);
224
224
  const quoted = names.map((name) => quoteIdent(name)).join(', ');
225
225
  const values = placeholderList(names.length, dialect);
226
- if (dialect === 'sqlite') {
227
- // INSERT OR REPLACE keys on the (_sync_partition, _sync_row_id) PK.
228
- return `INSERT OR REPLACE INTO ${quoteIdent(table.name)} (${quoted}) VALUES (${values})`;
229
- }
230
226
  const updates = names
231
227
  .slice(2) // partition + row id are the conflict key
232
- .map((name) => `${quoteIdent(name)}=EXCLUDED.${quoteIdent(name)}`)
228
+ .map((name) => `${quoteIdent(name)}=excluded.${quoteIdent(name)}`)
233
229
  .join(', ');
234
230
  return `INSERT INTO ${quoteIdent(table.name)} (${quoted}) VALUES (${values})
235
231
  ON CONFLICT (${quoteIdent(SYNC_PARTITION_COLUMN)}, ${quoteIdent(SYNC_ROW_ID_COLUMN)}) DO UPDATE SET ${updates}`;
@@ -2,8 +2,8 @@
2
2
  * Shared SQLite dialect for the two SQLite-family storages: `bun:sqlite`
3
3
  * (synchronous, `SqliteServerStorage`) and Cloudflare D1 (async,
4
4
  * `D1ServerStorage`). D1 *is* SQLite — same DDL, same statement grammar,
5
- * same `?` positional placeholders, same `INSERT OR REPLACE` / `INSERT OR
6
- * IGNORE` upsert idioms — so the schema and the value (de)serialization are
5
+ * same `?` positional placeholders, same `INSERT ... ON CONFLICT` / `INSERT
6
+ * OR IGNORE` upsert idioms — so the schema and the value (de)serialization are
7
7
  * genuinely common ground and live here.
8
8
  *
9
9
  * What is NOT shared: statement *execution*. `bun:sqlite` is sync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/server",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Syncular server: handleSyncRequest + storage/auth interfaces for the sync protocol",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -53,7 +53,7 @@
53
53
  "!dist/**/*.test.d.ts"
54
54
  ],
55
55
  "dependencies": {
56
- "@syncular/core": "0.13.0"
56
+ "@syncular/core": "0.15.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@electric-sql/pglite": "^0.5.4"
@@ -261,13 +261,9 @@ export function upsertSql(
261
261
  const names = tableColumnNames(table);
262
262
  const quoted = names.map((name) => quoteIdent(name)).join(', ');
263
263
  const values = placeholderList(names.length, dialect);
264
- if (dialect === 'sqlite') {
265
- // INSERT OR REPLACE keys on the (_sync_partition, _sync_row_id) PK.
266
- return `INSERT OR REPLACE INTO ${quoteIdent(table.name)} (${quoted}) VALUES (${values})`;
267
- }
268
264
  const updates = names
269
265
  .slice(2) // partition + row id are the conflict key
270
- .map((name) => `${quoteIdent(name)}=EXCLUDED.${quoteIdent(name)}`)
266
+ .map((name) => `${quoteIdent(name)}=excluded.${quoteIdent(name)}`)
271
267
  .join(', ');
272
268
  return `INSERT INTO ${quoteIdent(table.name)} (${quoted}) VALUES (${values})
273
269
  ON CONFLICT (${quoteIdent(SYNC_PARTITION_COLUMN)}, ${quoteIdent(SYNC_ROW_ID_COLUMN)}) DO UPDATE SET ${updates}`;
@@ -2,8 +2,8 @@
2
2
  * Shared SQLite dialect for the two SQLite-family storages: `bun:sqlite`
3
3
  * (synchronous, `SqliteServerStorage`) and Cloudflare D1 (async,
4
4
  * `D1ServerStorage`). D1 *is* SQLite — same DDL, same statement grammar,
5
- * same `?` positional placeholders, same `INSERT OR REPLACE` / `INSERT OR
6
- * IGNORE` upsert idioms — so the schema and the value (de)serialization are
5
+ * same `?` positional placeholders, same `INSERT ... ON CONFLICT` / `INSERT
6
+ * OR IGNORE` upsert idioms — so the schema and the value (de)serialization are
7
7
  * genuinely common ground and live here.
8
8
  *
9
9
  * What is NOT shared: statement *execution*. `bun:sqlite` is sync