Open Fryuni opened 2 years ago
Even crazier:
CREATE TABLE foo
(
id int NOT NULL PRIMARY KEY,
value citext NOT NULL
);
-- Insert without index
insert into "foo" ("id", "value")
values (1, 'foo');
-- Selecting without index: doesn't work
select * from foo where "value" = 'Foo';
select * from foo where "value" = 'foo';
select * from foo where "value" = 'Foo'::citext; -- Works with explicit casting
CREATE INDEX foo_value ON foo ("value");
-- Select with index, but data added before index: works!
select * from foo where "value" = 'Foo';
select * from foo where "value" = 'foo';
-- Insert with index
insert into "foo" ("id", "value")
values (2, 'foo-bar');
-- Select with index, data added with index: doesn't work!
select * from foo where "value" = 'Foo-Bar';
select * from foo where "value" = 'foo-bar';
select * from foo where "value" = 'Foo-Bar'::citext; -- Not even with explicit casting
-- But only the last...
insert into "foo" ("id", "value")
values (3, 'foobar');
select * from foo where "value" = 'FooBar';
select * from foo where "value" = 'foobar';
-- As soon as a new entry is added, the previous entries work!
-- But only if they share a prefix up to a `-` apparently 🤔... weird 😕
select * from foo where "value" = 'Foo-Bar';
select * from foo where "value" = 'foo-bar';
Describe the bug
Parameters of data type
text
are being coerced tocitext
when writing data, but not when comparing.To Reproduce
On a real postgres all of the above returns the inserted row:
pg-mem version
2.6.3