Skip to content

Commit

Permalink
Add a test for Workers SDK issue
Browse files Browse the repository at this point in the history
The issue: cloudflare/workers-sdk#3160

The test is passing and it is proof of the expected behavior that Workers SDK doesn't match.
  • Loading branch information
kossnocorp committed May 25, 2024
1 parent 1d89f3b commit 6180dfc
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/cloudflare/internal/test/d1/d1-api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,4 +475,46 @@ export const test_d1_api = test(async (DB) => {
meta: meta({ rows_read: 3, rows_written: 0 }),
}
)

await itShould(
'properly JOIN columns with the same name',
() =>
DB.batch([
DB.prepare(
`CREATE TABLE organizations
(
id INTEGER PRIMARY KEY,
name TEXT
);`
),
DB.prepare(
`CREATE TABLE projects (
id INTEGER PRIMARY KEY,
name TEXT,
project_id INTEGER,
FOREIGN KEY (project_id) REFERENCES projects(id)
);`
)
]),
[
{ success: true, results: [], meta: anything },
{ success: true, results: [], meta: anything }
],
() =>
DB.batch([
DB.prepare(`INSERT INTO organizations (name) VALUES ('Cloudflare');`),
DB.prepare(`INSERT INTO projects (name, project_id) VALUES ('Cloudflare', 1);`),
]),
[
{ success: true, results: [], meta: anything },
{ success: true, results: [], meta: anything }
],
() =>
DB.prepare(
`SELECT "projects"."name", "organizations"."name"
FROM "projects"
JOIN "organizations" ON "projects"."project_id" = "organizations"."id";`
).raw(),
[['Cloudflare', 'Cloudflare']]
)
})

0 comments on commit 6180dfc

Please sign in to comment.