[wrangler] Include column names in D1 SQL export#12277
Conversation
🦋 Changeset detectedLatest commit: a2be02c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Claude finished @penalosa's task —— View job Changeset ReviewTodo List
✅ All changesets look good The changeset at
|
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
@claude this seems to be failing tests. Can you analyse and fix? |
|
Claude finished @penalosa's task —— View job ✅ Tests Fixed Successfully!Todo List
Issue Identified and FixedThe tests were failing because they expected the old INSERT format without column names: INSERT INTO "foo" VALUES(1,'xxx');But after your changes to include column names in D1 SQL exports, the code now generates: INSERT INTO "foo" ("id","value") VALUES(1,'xxx');Changes MadeUpdated test expectations in
The fix has been committed and pushed to the PR branch. The tests should now pass with the new column name format. |
alsuren
left a comment
There was a problem hiding this comment.
I think I agree with this. We are diverging from the sqlite .dump command, and making the output more verbose, but it should make things more robust (sqlite column ordering is notoriously fragile).
@penalosa Let's hold off on merging this until we're ready to merge the internal copy of it as well, just in case there is anything we've not thought of (I tagged you in my gitlab MR for this).
dario-piotrowicz
left a comment
There was a problem hiding this comment.
This needs to wait until the internal PR has landed
|
I just pushed a tweak to make it match what we're planning to ship in our next release (we checked the stats already and don't expect to break any databases that aren't already broken). |
1d145a7 to
609e2fc
Compare
609e2fc to
dd50c1f
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers |
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
|
✅ All changesets look good |
@dario-piotrowicz this has been out in prod for a few months with no problems. |
…T statements
The dumpSql function now includes column names in INSERT statements.
Updated test expectations to match the new format:
- INSERT INTO "table" VALUES(...) → INSERT INTO "table" ("col1","col2") VALUES(...)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Somhairle MacLeòid <penalosa@users.noreply.github.com>
Add stats tracking for INSERT statement sizes to help analyze the impact of including column names in D1 SQL exports. This syncs the miniflare dumpSql.ts with the d1-worker version from GitLab MR 1056.
dd50c1f to
51c853c
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers |
af61e9b to
a2be02c
Compare
PR is unblocked and ready for review
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Somhairle MacLeòid <penalosa@users.noreply.github.com> Co-authored-by: David Laban <dlaban@cloudflare.com> Co-authored-by: Pete Bacon Darwin <pbacondarwin@cloudflare.com>
Fixes #7507.
D1 SQL exports now include column names in INSERT statements. Previously, exports generated:
Now exports generate:
This ensures that exported SQL can be successfully imported even when the target table has columns in a different order than the original, which commonly occurs during iterative development when schemas evolve.