As expected, when doing an equality test like this, the comparison succeeds:
CREATE TABLE citext_test (
value citext PRIMARY KEY
);
INSERT INTO citext_test VALUES ('one');
INSERT INTO citext_test VALUES ('two');
SELECT * FROM citext_test WHERE value = 'One';
However, if the value being compared against is of type 'text', the comparison fails:
SELECT * FROM citext_test WHERE value = 'One'::text;
Using EXPLAIN, it appears the raw value in the first example is cast to CITEXT:
Index Only Scan using citext_test_pkey on citext_test (cost=0.15..8.17 rows=1 width=32)
Index Cond: (value = 'One'::citext)
I'd like to compare against TEXT columns from joined tables. Do I really need to cast these columns to CITEXT to get comparisons to work? I thought part of the advantage of using CITEXT was not having to remember to add things like this (e.g. LOWER(some_value));