rockdai / sql-bricks

Transparent, Schemaless SQL Generation
http://csnw.github.io/sql-bricks
MIT License
213 stars 25 forks source link

how to use overlap(&&) operator? #69

Closed SanderElias closed 9 years ago

SanderElias commented 9 years ago

I have this: select * from table where ARRAY['a tag','antoher'] && tags in English, I have an field (tags) that is an array of text fields. Now I need to get all records that have any of the items in an array.

How do I express this with sql-bricks? I know it's an PostgreSQL extension, but I think it needs another operator.

prust commented 9 years ago

@SanderElias: Postgres-specific functionality is in the https://github.com/Suor/sql-bricks-postgres repository. Maybe you could submit a pull request there for the addition of the && operator. There is already an "ilike" operator being added there (in postgres.js), so it shouldn't be hard to use that as a template since your code should be very similar. Not sure what you would call it, since "&&" isn't a valid method name in JS, maybe "andand()" or "doubleand()" or "overlap()"?