|
|
Additional Arel features. In order to provide correct and smooth statements for the new features provided by this GEM, a bunch of Arel extensions where provided.
|
|
|
|
|
|
### Inflix operators
|
|
|
|
|
|
PostgreSQL allows a bunch of custom operators while working with [Arrays](https://www.postgresql.org/docs/9.6/functions-array.html), [Ranges](https://www.postgresql.org/docs/9.6/functions-range.html), and [Hashes](https://www.postgresql.org/docs/9.6/hstore.html).
|
|
|
|
|
|
These are the ones implemented and can be used with Arel nodes and attributes:
|
|
|
|
|
|
- `.overlaps` => &&
|
|
|
- `.contains` => @>
|
|
|
- `.contained_by` => <@
|
|
|
- `.has_key` => ?
|
|
|
- `.has_all_keys` => ?&
|
|
|
- `.has_any_keys` => ?|
|
|
|
- `.strictly_left` => <<
|
|
|
- `.strictly_right` => >>
|
|
|
- `.doesnt_right_extend` => &<
|
|
|
- `.doesnt_left_extend` => &>
|
|
|
- `.adjacent_to` => -|-
|
|
|
|
|
|
### Cast values
|
|
|
|
|
|
One of the things that allowed array associations and the period operations is being able to cast things from one type to another right on Arel. This means that time columns can be casted into dates and have all the capabilities of a normal Arel node.
|
|
|
|
|
|
If you are used to Arel, to cast something it's pretty simple:
|
|
|
```ruby
|
|
|
Event.arel_table[:created_at].cast(:date)
|
|
|
```
|
|
|
which will produce
|
|
|
```
|
|
|
"events"."created_at"::date
|
|
|
``` |
|
|
\ No newline at end of file |