It seems like pg-mem does not support IF NOT EXISTS on table creation. A few of my tables require other tables to exist beforehand, so for tests I am auto-creating any table dependencies as I go. Since some of those dependencies overlap, I rely on IF NOT EXISTS to smooth things out when a table has already been auto-created beforehand.
I'll dive into the codebase and see if I can implement this feature myself, but documenting it here all the same.
To Reproduce
Fails on playground:
CREATE TABLE IF NOT EXISTS "user" ("id" SERIAL NOT NULL, "name" text NOT NULL, PRIMARY KEY ("id"));
CREATE TABLE IF NOT EXISTS "user" ("id" SERIAL NOT NULL, "name" text NOT NULL, PRIMARY KEY ("id"));
Error
🔨 Not supported 🔨 : The query you ran generated an AST which parts have not been read by the query planner. This means that those parts could be ignored:
⇨ .columns[0].constraints[0].type ("not null")
⇨ .columns[1].constraints[0].type ("not null")
⇨ .constraints[0].type ("primary key")
⇨ .constraints[0].columns[0].name ("id")
⇨ .constraints[0].columns ([{"name":"id","_location":{"start":209,"end":213}}])
👉 pg-mem is work-in-progress, and it would seem that you've hit one of its limits.
*️⃣ Reconsituted failed SQL statement: CREATE TABLE IF NOT EXISTS "user" (id serial not null , name text not null , primary key (id) )
It seems like
pg-mem
does not supportIF NOT EXISTS
on table creation. A few of my tables require other tables to exist beforehand, so for tests I am auto-creating any table dependencies as I go. Since some of those dependencies overlap, I rely onIF NOT EXISTS
to smooth things out when a table has already been auto-created beforehand.I'll dive into the codebase and see if I can implement this feature myself, but documenting it here all the same.
To Reproduce
Fails on playground:
Error