Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-files-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": minor
---

feature: Improved `d1 execute --file --remote` performance & added support for much larger SQL files within a single transaction.
1 change: 1 addition & 0 deletions packages/wrangler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"jest": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"jest-websocket-mock": "^2.5.0",
"md5-file": "5.0.0",
"mime": "^3.0.0",
"minimatch": "^5.1.0",
"msw": "^0.49.1",
Expand Down
27 changes: 27 additions & 0 deletions packages/wrangler/src/__tests__/d1/execute.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import fs from "node:fs";
import { join } from "path";
import { mockConsoleMethods } from "../helpers/mock-console";
import { useMockIsTTY } from "../helpers/mock-istty";
import { runInTempDir } from "../helpers/run-in-tmp";
Expand Down Expand Up @@ -87,4 +89,29 @@ describe("execute", () => {
)
);
});

it("should reject a binary SQLite DB", async () => {
setIsTTY(false);
writeWranglerToml({
d1_databases: [
{ binding: "DATABASE", database_name: "db", database_id: "xxxx" },
],
});
const path = join(__dirname, "fixtures", "db.sqlite3");
fs.copyFileSync(path, "db.sqlite3");

await expect(
runWrangler(`d1 execute db --file db.sqlite3 --local --json`)
).rejects.toThrowError(
JSON.stringify(
{
error: {
text: "Provided file is a binary SQLite database file instead of an SQL text file. The execute command can only process SQL text files. Please export an SQL file from your SQLite database and try again.",
},
},
null,
2
)
);
});
});
Binary file not shown.
2 changes: 0 additions & 2 deletions packages/wrangler/src/d1/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const DEFAULT_MIGRATION_PATH = "./migrations";
export const DEFAULT_MIGRATION_TABLE = "d1_migrations";
export const LOCATION_CHOICES = ["weur", "eeur", "apac", "oc", "wnam", "enam"];
// Max number of statements to send in a single /execute call
export const DEFAULT_BATCH_SIZE = 10_000;
Loading