luckyframework/avram

Support Array of citext `citext[]` column

オープン

#970 opened on 2023/09/11

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)Crystal (67 件のフォーク)auto 404
hacktoberfest

Repository metrics

Stars
 (180 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Avram currently supports Array(String), but if you need to search an array with case insensitive, then things get a little hairy

(assuming you have a GIN index on this column...)

=# select username from users where tags @> array['Lucky'];
  username   
-------------
 jeremy
(1 row)

Time: 0.438 ms
=# select username from users where tags @> array['LUCKY'];
  username   
-------------
(0 rows)

Time: 0.815 ms
=# select username from users where lower(tags::text)::text[] @> array['lucky'];
  username   
-------------
 jeremy
(1 row)

Time: 36.088 ms

Now if you use a citext[] column instead..

=# select username from users where tags @> array['LUCKY']::citext[];
  username   
-------------
 jeremy
(1 row)

Time: 0.395 ms
=# select username from users where tags @> array['lUcKy']::citext[];
  username   
-------------
 jeremy
(1 row)

Time: 0.408 ms

コントリビューターガイド