Skip to content

D1 export by Wrangler did not escape the literal \n properly #9042

Closed
@Func86

Description

@Func86

Which Cloudflare product(s) does this pertain to?

D1

What versions & operating system are you using?

Wrangler 4.13.0

Please provide a link to a minimal reproduction

No response

Describe the Bug

  • Create a table with a text column, and add some data with both the literal \n and normal linebreaks
  • Export the database with the Wrangler command wrangler d1 export <db_name> --remote --output=./test.sql
  • Inspect the SQL file downloaded

Image

PRAGMA defer_foreign_keys=TRUE;
CREATE TABLE [test] ("test_text" text);
INSERT INTO test VALUES('AAA\nAAA');
INSERT INTO test VALUES(replace('AAA\nAAA','\n',char(10)));
INSERT INTO test VALUES(replace('AAA\nAAA\nBBB','\n',char(10)));

In this table, the first record contains only the literal \n, the second one contains only linebreaks, these two appear intact.
However, the third one was messed up, and the literal \n was converted to linebreaks.

Please provide any relevant error logs

No response

Metadata

Metadata

Assignees

Labels

awaiting Cloudflare responseAwaiting response from workers-sdk maintainer teambugSomething that isn't workingd1Relating to D1

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions