Skip to content

Commit

Permalink
update from != to IS NOT
Browse files Browse the repository at this point in the history
  • Loading branch information
tantaman committed Apr 24, 2023
1 parent 30f5098 commit a1c99b8
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ In other words, you can write to your SQLite database while offline. I can write
All of the above involve a merging of independent edits problem. If your database can handle this for you, you don't need custom code in your application to handle those 5 cases.

Discussions of these problems in the application space:

- [Meta Muse](https://museapp.com/podcast/56-sync/)
- [FB Messenger re-write](https://softwareengineeringdaily.com/2020/03/31/facebook-messenger-engineering-with-mohsen-agsen/)

Expand All @@ -48,7 +49,7 @@ The full documentation site is available [here](https://vlcn.io/docs/getting-sta
- `SELECT crsql_as_crr('table_name')`
- A virtual table (`crsql_changes`) to ask the database for changesets or to apply changesets from another database
- `SELECT * FROM crsql_changes WHERE db_version > x AND site_id IS NULL` -- to get local changes
- `SELECT * FROM crsql_changes WHERE db_version > x AND site_id != some_site` -- to get all changes excluding those synced from some site
- `SELECT * FROM crsql_changes WHERE db_version > x AND site_id IS NOT some_site` -- to get all changes excluding those synced from some site
- `INSERT INTO crsql_changes VALUES ([patches receied from select on another peer])`
- And `crsql_alter_begin('table_name')` & `crsql_alter_commit('table_name')` primitives to allow altering table definitions that have been upgraded to `crr`s.
- Until we move forward with extending the syntax of SQLite to be CRR aware, altering CRRs looks like:
Expand Down Expand Up @@ -292,7 +293,6 @@ JS APIs for using `cr-sqlite` in the browser are not yet documented but exist in
- [Observable Notebook](https://observablehq.com/@tantaman/cr-sqlite-basic-setup)
- https://github.com/vlcn-io/live-examples
# Research & Prior Art
cr-sqlite was inspired by and built on ideas from these papers:
Expand Down
2 changes: 1 addition & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The full documentation site is available [here](https://vlcn.io/docs/getting-sta
- `SELECT crsql_as_crr('table_name')`
- A virtual table (`crsql_changes`) to ask the database for changesets or to apply changesets from another database
- `SELECT * FROM crsql_changes WHERE db_version > x AND site_id IS NULL` -- to get local changes
- `SELECT * FROM crsql_changes WHERE db_version > x AND site_id != some_site` -- to get all changes excluding those synced from some site
- `SELECT * FROM crsql_changes WHERE db_version > x AND site_id IS NOT some_site` -- to get all changes excluding those synced from some site
- `INSERT INTO crsql_changes VALUES ([patches receied from select on another peer])`
- And `crsql_alter_begin('table_name')` & `crsql_alter_commit('table_name')` primitives to allow altering table definitions that have been upgraded to `crr`s.
- Until we move forward with extending the syntax of SQLite to be CRR aware, altering CRRs looks like:
Expand Down
2 changes: 1 addition & 1 deletion core/src/changes-vtab.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* To fetch a changeset:
* ```sql
* SELECT * FROM crsql_chages WHERE site_id != SITE_ID AND version > V
* SELECT * FROM crsql_chages WHERE site_id IS NOT SITE_ID AND version > V
* ```
*
* The site id parameter is used to prevent a site from fetching its own
Expand Down
2 changes: 1 addition & 1 deletion js/packages/node-tests/src/__tests__/xplat.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(global as any).navigator = {};
import "../fill.js";

import { test, expect } from "vitest";
import { DBAsync, DB as DBSync } from "@vlcn.io/xplat-api";
Expand Down
1 change: 1 addition & 0 deletions js/packages/node-tests/src/fill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(global as any).navigator = {};
2 changes: 1 addition & 1 deletion js/packages/p2p/src/WholeDbReplicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class WholeDbReplicator {
const fromAsBlob = uuidParse(from);
// The casting is due to bigint support problems in various wasm builds of sqlite
const changes: Changeset[] = await this.db.execA<Changeset>(
`SELECT "table", "pk", "cid", "val", "col_version", "db_version", "site_id" FROM crsql_changes WHERE site_id != ? AND db_version > ?`,
`SELECT "table", "pk", "cid", "val", "col_version", "db_version", COALESCE("site_id", crsql_siteid()) FROM crsql_changes WHERE site_id IS NOT ? AND db_version > ?`,
[fromAsBlob, since]
);

Expand Down
2 changes: 1 addition & 1 deletion js/packages/server-core/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DB {
this.#applySchema(create.schemaName);
}
this.#pullChangesetStmt = this.#db.prepare(
`SELECT "table", "pk", "cid", "val", "col_version", "db_version" FROM crsql_changes WHERE db_version > ? AND site_id != ?`
`SELECT "table", "pk", "cid", "val", "col_version", "db_version" FROM crsql_changes WHERE db_version > ? AND site_id IS NOT ?`
);
this.#pullChangesetStmt.raw(true);

Expand Down
2 changes: 1 addition & 1 deletion js/packages/xplat-tests/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { tests as wdbTests } from "./WholeDbRepliator.test.js";
export { tests as tblrxTests } from "./tblrx.test.js";
export {tests as intTests} from './int.test.js';
export { tests as intTests } from "./int.test.js";

0 comments on commit a1c99b8

Please sign in to comment.