luckyframework/avram

Support Array of citext `citext[]` column

开放

#970 创建于 2023年9月11日

 (2 条评论) (0 个反应) (0 位负责人)Crystal (67 个派生)auto 404
hacktoberfest

仓库指标

星标
 (180 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南