Skip to content

Commit 58c1ef7

Browse files
subsetparkclaude
andcommitted
patches: rename sqlite3-worker to sqlite3-dot-commands
Upstream vercel-labs#190 (merged 2026-04-30, brought in via the just-bash@2.14.4 sync) fixed the worker bundling bug — published tarballs now ship dist/commands/sqlite3/worker.js, and there's an upstream regression test for the resolver. That half of the carry is no longer ours. The half we still carry is the dot-command preprocessor (commands/sqlite3/dot-commands.ts), which translates .tables, .schema, .mode, .read, .separator, .quit, etc. before handing the script to sql.js. Nothing equivalent exists upstream. - Rename the integration-test describe block and update its coverage to exercise the actual carry: SQL replacement (.tables, .schema), formatter mutation (.mode csv), and file inlining (.read). Drop the "ships the bundled worker" case — it's now testing upstream behavior. - Update the README patch table accordingly, with a parenthetical linking to vercel-labs#190 for history. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 353b08d commit 58c1ef7

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
>
1313
> | Patch | What it fixes | Upstream PR |
1414
> | --- | --- | --- |
15-
> | `sqlite3-worker` | The published npm tarball omits `dist/commands/sqlite3/worker.js`, so the bundled `sqlite3` command falls through to the Python worker and throws on every invocation. We ship the worker. | _filed in Patch 2_ |
15+
> | `sqlite3-dot-commands` | sql.js doesn't implement sqlite3's CLI dot-commands (`.tables`, `.schema`, `.mode`, `.read`, `.separator`, `.quit`, etc.), so agent scripts pasted from real `sqlite3` sessions hit syntax errors. We carry a preprocessor (`commands/sqlite3/dot-commands.ts`) that translates each dot-command to equivalent SQL, formatter-state mutations, recursive `.read` inlining, or actionable in-band error messages before handing the script to the worker. (The original `sqlite3-worker` bundling bug was upstreamed in [vercel-labs#190](https://github.com/vercel-labs/just-bash/pull/190).) | _filed in Patch 2_ |
1616
> | `awk-comma-continuation` | The bundled awk lexer emits a `NEWLINE` token after a trailing comma, breaking POSIX comma-continuation in scripts our agent runs. | _filed in Patch 2_ |
1717
> | `jq-permissive-control-chars` | The bundled jq input scanner calls `JSON.parse` on raw bytes that may contain literal control characters (which Shopify's Admin API responses do), failing parse. We sanitize the slice before parsing. | _filed in Patch 2_ |
1818
>

packages/just-bash/src/flowglad-patches.integration.test.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,57 @@ import { Bash } from "./Bash.js";
55
// Adding a new patch requires adding a corresponding describe block here so
66
// the consumability CI gates the next release on it.
77
describe("Flowglad carried patches", () => {
8-
describe("sqlite3-worker", () => {
9-
it("ships the bundled worker so basic SQL runs", async () => {
8+
describe("sqlite3-dot-commands", () => {
9+
it("translates the .tables dot-command into a sqlite_master query", async () => {
1010
const env = new Bash();
1111

1212
const result = await env.exec(
13-
'sqlite3 :memory: "CREATE TABLE t(x); INSERT INTO t VALUES(42); SELECT x FROM t"',
13+
'sqlite3 :memory: "CREATE TABLE alpha(x); CREATE TABLE beta(y); .tables"',
1414
);
1515

1616
expect(result.stderr).toBe("");
17-
expect(result.stdout).toBe("42\n");
17+
expect(result.stdout).toBe("alpha\nbeta\n");
1818
expect(result.exitCode).toBe(0);
1919
});
2020

21-
it("translates the .tables dot-command into a sqlite_master query", async () => {
21+
it("translates the .schema dot-command into a sqlite_master query", async () => {
2222
const env = new Bash();
2323

2424
const result = await env.exec(
25-
'sqlite3 :memory: "CREATE TABLE alpha(x); CREATE TABLE beta(y); .tables"',
25+
'sqlite3 :memory: "CREATE TABLE alpha(x INTEGER); .schema alpha"',
2626
);
2727

2828
expect(result.stderr).toBe("");
29-
expect(result.stdout).toBe("alpha\nbeta\n");
29+
// .schema appends `;` to each CREATE statement to match real sqlite3.
30+
expect(result.stdout).toBe("CREATE TABLE alpha(x INTEGER);\n");
3031
expect(result.exitCode).toBe(0);
3132
});
3233

33-
it("translates the .schema dot-command into a sqlite_master query", async () => {
34+
it(".mode csv mutates the formatter for downstream SQL", async () => {
3435
const env = new Bash();
3536

3637
const result = await env.exec(
37-
'sqlite3 :memory: "CREATE TABLE alpha(x INTEGER); .schema alpha"',
38+
'sqlite3 :memory: "CREATE TABLE t(a,b); INSERT INTO t VALUES(1,2),(3,4); .mode csv\nSELECT * FROM t"',
3839
);
3940

4041
expect(result.stderr).toBe("");
41-
// .schema appends `;` to each CREATE statement to match real sqlite3.
42-
expect(result.stdout).toBe("CREATE TABLE alpha(x INTEGER);\n");
42+
expect(result.stdout).toBe("1,2\n3,4\n");
43+
expect(result.exitCode).toBe(0);
44+
});
45+
46+
it(".read inlines the contents of a referenced script", async () => {
47+
const env = new Bash({
48+
files: {
49+
"/seed.sql": "CREATE TABLE t(x);\nINSERT INTO t VALUES(7);\n",
50+
},
51+
});
52+
53+
const result = await env.exec(
54+
'sqlite3 :memory: ".read /seed.sql\nSELECT x FROM t"',
55+
);
56+
57+
expect(result.stderr).toBe("");
58+
expect(result.stdout).toBe("7\n");
4359
expect(result.exitCode).toBe(0);
4460
});
4561
});

0 commit comments

Comments
 (0)