Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: D1 export will fail if a table column is named "index" #6675

Open
OpenSource03 opened this issue Sep 11, 2024 · 0 comments
Open

🐛 BUG: D1 export will fail if a table column is named "index" #6675

OpenSource03 opened this issue Sep 11, 2024 · 0 comments
Labels
bug Something that isn't working d1 Relating to D1

Comments

@OpenSource03
Copy link

Which Cloudflare product(s) does this pertain to?

D1, Wrangler

What version(s) of the tool(s) are you using?

3.76.0 (Wrangler)

What version of Node are you using?

20

What operating system and version are you using?

MacOS 15.1 Beta

Describe the Bug

Observed behavior

D1 export fails if there is a table named "index"

Expected behavior

I guess, if that's not an SQLite related thing, and most likely is not, as I am able to create the table with these column naming, there should be no error.

Steps to reproduce

Make a database, for example, with the following model

model Status {
  id    Int    @id @default(autoincrement())
  index Int    @default(0)
  name  String
  color String
  text  String
  icon  String
  posts Post[]
}

Insert a few rows of random data and try to export it.

My data:

┌────┬───────┬───────────────┬─────────┬─────────────────────────┬──────────────────┐
│ id │ index │ name          │ color   │ text                    │ icon             │
├────┼───────┼───────────────┼─────────┼─────────────────────────┼──────────────────┤
│ 0  │ 1     │ Native        │ #10b981 │ Yes, natively supported │ CheckmarkRegular │
├────┼───────┼───────────────┼─────────┼─────────────────────────┼──────────────────┤
│ 1  │ 1     │ Emulated      │ green   │ Active                  │ check            │
├────┼───────┼───────────────┼─────────┼─────────────────────────┼──────────────────┤
│ 2  │ 2     │ Not supported │ yellow  │ Pending                 │ clock            │
├────┼───────┼───────────────┼─────────┼─────────────────────────┼──────────────────┤
│ 3  │ 3     │ Beta Support  │ red     │ Inactive                │ x                │
└────┴───────┴───────────────┴─────────┴─────────────────────────┴──────────────────┘

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

 ⛅️ wrangler 3.76.0
-------------------

🌀 Exporting local database windows-on-arm (87be6381-bcc2-45d5-a843-f2cec24a69f0) from .wrangler/state/v3/d1:
🌀 To export your remote database, add a --remote flag to your wrangler command.
🌀 Exporting SQL to ./export/posts.sql...

✘ [ERROR] D1_ERROR: Failed to parse body as JSON, got: Error: near "index": syntax error at offset 11: SQLITE_ERROR

      at dumpSql
  (file:///Users/dejanzegarac/PhpstormProjects/windowsonarm-cf/node_modules/.pnpm/[email protected]/node_modules/miniflare/dist/src/workers/d1/database.worker.js:49:65)
      at dumpSql.next (<anonymous>)
      at Function.from (<anonymous>)
      at #doExportData
  (file:///Users/dejanzegarac/PhpstormProjects/windowsonarm-cf/node_modules/.pnpm/[email protected]/node_modules/miniflare/dist/src/workers/d1/database.worker.js:337:23)
      at D1DatabaseObject.queryExecute
  (file:///Users/dejanzegarac/PhpstormProjects/windowsonarm-cf/node_modules/.pnpm/[email protected]/node_modules/miniflare/dist/src/workers/d1/database.worker.js:320:32)
      at async D1DatabaseObject.fetch
  (file:///Users/dejanzegarac/PhpstormProjects/windowsonarm-cf/node_modules/.pnpm/[email protected]/node_modules/miniflare/dist/src/workers/shared/index.worker.js:377:18)
      at async D1DatabaseObject.fetch
  (file:///Users/dejanzegarac/PhpstormProjects/windowsonarm-cf/node_modules/.pnpm/[email protected]/node_modules/miniflare/dist/src/workers/shared/index.worker.js:542:14)


🪵  Logs were written to "/Users/dejanzegarac/.wrangler/logs/wrangler-2024-09-11_11-20-25_015.log"
@OpenSource03 OpenSource03 added the bug Something that isn't working label Sep 11, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Sep 11, 2024
@CarmenPopoviciu CarmenPopoviciu added the d1 Relating to D1 label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working d1 Relating to D1
Projects
None yet
Development

No branches or pull requests

2 participants