diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/nodes/binary.rb | 2 | ||||
-rw-r--r-- | lib/arel/visitors/depth_first.rb | 2 | ||||
-rw-r--r-- | lib/arel/visitors/postgresql.rb | 8 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 8 |
4 files changed, 20 insertions, 0 deletions
diff --git a/lib/arel/nodes/binary.rb b/lib/arel/nodes/binary.rb index 0e7e281b4b..939684957f 100644 --- a/lib/arel/nodes/binary.rb +++ b/lib/arel/nodes/binary.rb @@ -40,7 +40,9 @@ module Arel Matches NotEqual NotIn + NotRegexp Or + Regexp Union UnionAll Intersect diff --git a/lib/arel/visitors/depth_first.rb b/lib/arel/visitors/depth_first.rb index 7043e5d527..4d2ecfa5e1 100644 --- a/lib/arel/visitors/depth_first.rb +++ b/lib/arel/visitors/depth_first.rb @@ -79,8 +79,10 @@ module Arel alias :visit_Arel_Nodes_Matches :binary alias :visit_Arel_Nodes_NotEqual :binary alias :visit_Arel_Nodes_NotIn :binary + alias :visit_Arel_Nodes_NotRegexp :binary alias :visit_Arel_Nodes_Or :binary alias :visit_Arel_Nodes_OuterJoin :binary + alias :visit_Arel_Nodes_Regexp :binary alias :visit_Arel_Nodes_RightOuterJoin :binary alias :visit_Arel_Nodes_TableAlias :binary alias :visit_Arel_Nodes_Values :binary diff --git a/lib/arel/visitors/postgresql.rb b/lib/arel/visitors/postgresql.rb index 812710181c..49f7482e7d 100644 --- a/lib/arel/visitors/postgresql.rb +++ b/lib/arel/visitors/postgresql.rb @@ -11,6 +11,14 @@ module Arel "#{visit o.left} NOT ILIKE #{visit o.right}" end + def visit_Arel_Nodes_Regexp o + "#{visit o.left} ~ #{visit o.right}" + end + + def visit_Arel_Nodes_NotRegexp o + "#{visit o.left} !~ #{visit o.right}" + end + def visit_Arel_Nodes_DistinctOn o "DISTINCT ON ( #{visit o.expr} )" end diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 5b71291f0b..84034829a5 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -435,6 +435,14 @@ module Arel "#{visit o.left} NOT LIKE #{visit o.right}" end + def visit_Arel_Nodes_Regexp o + raise NotImplementedError, '~ not implemented for this db' + end + + def visit_Arel_Nodes_NotRegexp o + raise NotImplementedError, '!~ not implemented for this db' + end + def visit_Arel_Nodes_JoinSource o [ (visit(o.left) if o.left), |