Closed geelen closed 5 days ago
Latest commit: 6f94501465ed021ccc24d0c4c9436df295596086
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
A wrangler prerelease is available for testing. You can install this latest build in your project with:
npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9691836885/npm-package-wrangler-6073
You can reference the automatically updated head of this PR with:
npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6073/npm-package-wrangler-6073
Or you can use npx
with this latest build directly:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9691836885/npm-package-wrangler-6073 dev path/to/script.js
wrangler@3.62.0
includes the following runtime dependencies:
Package | Constraint | Resolved |
---|---|---|
miniflare |
workspace:* | 3.20240620.0 |
workerd |
1.20240620.1 | 1.20240620.1 |
workerd --version |
1.20240620.1 | 2024-06-20 |
Please ensure constraints are pinned, and miniflare
/workerd
minor versions match.
For my own education, does this PR mean that
PRAGMA miniflare_d1_export(?,?,?);
is part of our public API now? I don't think we want it to be so. How do we prevent people from writing that in their own queries?
It's part of miniflare's implementation of D1, but not present anywhere else. It's not accessible from wrangler d1 execute --local
since you can't pass parameters but technically if someone wrote it in a worker and passed in at least two params they'd get a sql dump in local dev (and an error in production).
We could refactor dumpSql
in this PR to use the public D1 API rather than the internal DO one (and then wrangler export
would just send lots of queries to the D1 rather than a single debug pragma), but that would mean it's much harder to reuse the specific dumpSql
code that's present in D1's internal codebase. And so I've erred on the side of making it easier to keep them consistent and accept leaking an implementation detail.
Ideally, Miniflare would make it possible to do an end-run around the D1 shim and hit an object directly with an RPC call, but as far as I can find out that's not possible.
This uses a new miniflare-only debug pragma
PRAGMA miniflare_d1_export
to trigger the dump as D1 provides no in-Worker API (which Miniflare uses) to generate exports.I'm open to other ways to implement this.
What this PR solves / how to test
Fixes limitation with the previous iteration of the export functionality. Previously, all
d1 export --local
commands would fail.Author has addressed the following
--local
doesn't work, it just emphasises--remote
(which still makes sense to be the default).