oguimbal / pg-mem

An in memory postgres DB instance for your unit tests
MIT License
1.96k stars 95 forks source link

Support add primary key #275

Open ranmocy opened 1 year ago

ranmocy commented 1 year ago

Describe the bug

I'm trying to alter table's primary key, but it fails even the primary key constraint was dropped before.

Table user already has a primary key

🐜 This seems to be an execution error, which means that your request syntax seems okay,
    but the resulting statement cannot be executed → Probably not a pg-mem error.

*️⃣ Reconsituted failed SQL statement: ALTER TABLE "user"  DROP CONSTRAINT user_pkey,  ADD primary key(name)

👉 You can file an issue at https://github.com/oguimbal/pg-mem along with a way to reproduce this error (if you can), and  the stacktrace:

To Reproduce

Reproducible with pg-mem playground: https://oguimbal.github.io/pg-mem-playground/

CREATE TABLE "user" ("id" SERIAL NOT NULL, "name" text NOT NULL, CONSTRAINT "user_pkey" PRIMARY KEY ("id"));
ALTER TABLE "user" DROP CONSTRAINT "user_pkey", ADD PRIMARY KEY(name);  # <= Error on this line

pg-mem version

2.6.3