tpetry / laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features
MIT License
772 stars 31 forks source link

Support for `ANY` and `ALL` array comparisons #33

Closed tpetry closed 2 years ago

tpetry commented 2 years ago

PostgreSQL supports interesting array comparison operators which can simply some queries:

SELECT * FROM users WHERE email ilike '%@gmail.com' OR email ilike '%outlook.com' OR email ilike '%@fastmail.com';

SELECT * FROM users WHERE email ilike ANY('{%@gmail.com,%@outlook.com,%@fastmail.com}');

With the Laravel query builder this could be used easily like the following:

$query->whereAny('column', 'like', ['pattern1%', 'pattern2%'])
$query->whereAll('column', 'like', ['abc%', '%xyz'])
tpetry commented 2 years ago

Released with 0.21.0