oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.35k stars 2.78k forks source link

Bun's Postgres doesn't support subqueries with duplicate names #15287

Open xorraxraxret opened 1 day ago

xorraxraxret commented 1 day ago

What version of Bun is running?

1.1.37-canary.10+61a3f0859

What platform is your computer?

Linux 6.11.0-9-generic x86_64 x86_64

What steps can reproduce the bug?

Run this query:

await sql`
  SELECT
    "categories"."id",
    "categories"."category_id",
    "sc"."id",
    "sc"."category_id"
  FROM
    "categories"
    INNER JOIN "categories" "sc" ON "categories"."id" = "sc"."category_id"
    LEFT JOIN (
      SELECT
        "subcategory_id"
      FROM
        "items"
      GROUP BY
        "items"."subcategory_id"
    ) "psc" ON "sc"."id" = "psc"."subcategory_id"
  WHERE
    "categories"."category_id" IS NULL
`

What is the expected behavior?

It should return the rows.

What do you see instead?

error: script was terminated by signal SIGABRT (Abort) 41611 IOT instruction (core dumped)

Additional information

I recall @Jarred-Sumner working on a fix for this, but it was never merged and I don't see it on the issue tracker, so maybe he forgot about it.

When this issue is fixed, I can start testing more complex use cases and reporting any issues.