oguimbal / pg-mem

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

Creating index on unique column results in not working unique constraint #349

Open dominik-zeglen opened 1 year ago

dominik-zeglen commented 1 year ago

Describe the bug

If you create index on a column that is defined as UNIQUE, it stops being unique if you add index to it. Defining it as CREATE UNIQUE INDEX fixes it but it behaves differently than postgres.

To Reproduce

create table a (
    id serial not null primary key,
    name varchar(32) not null unique
);

insert into a ("name") values ('foo');
CREATE INDEX a_name_index ON a USING btree (name);

insert into a ("name") values ('foo');
select * from a;

pg-mem version

2.6.13

krumft commented 1 year ago

This could be related to https://github.com/oguimbal/pg-mem/pull/333 - can you check if that PR fixes your problem?

oguimbal commented 11 months ago

this PR has been released as pg-mem@2.7.0, so feel free to close if that fixes your issue :)