diff options
author | Paul Sadauskas <psadauskas@gmail.com> | 2011-01-20 12:56:08 -0700 |
---|---|---|
committer | Paul Sadauskas <psadauskas@gmail.com> | 2011-01-21 17:25:12 -0700 |
commit | d532b7ee430c5d0c412ab9f1a5e0dd3ebc47f86b (patch) | |
tree | b6cd36d2643c2437db9778a250ce622e8b3432e0 /lib/arel/visitors/to_sql.rb | |
parent | dae7a245f8ec9f8eb5d9866938ea46ed7c88dcf1 (diff) | |
download | rails-d532b7ee430c5d0c412ab9f1a5e0dd3ebc47f86b.tar.gz rails-d532b7ee430c5d0c412ab9f1a5e0dd3ebc47f86b.tar.bz2 rails-d532b7ee430c5d0c412ab9f1a5e0dd3ebc47f86b.zip |
Add support for WITH and UNION
PostgreSQL WITH RECURSIVE support
Make WITH be a unary node
Diffstat (limited to 'lib/arel/visitors/to_sql.rb')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index d5534384f8..f3c8710068 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -129,6 +129,8 @@ eowarn def visit_Arel_Nodes_SelectStatement o [ + (visit(o.with) if o.with), + (visit(o.with_recursive) if o.with_recursive), o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join, ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?), (visit(o.limit) if o.limit), @@ -149,6 +151,22 @@ eowarn ].compact.join ' ' end + def visit_Arel_Nodes_With o + "WITH #{visit o.children}" + end + + def visit_Arel_Nodes_WithRecursive o + "WITH RECURSIVE #{visit o.children}" + end + + def visit_Arel_Nodes_Union o + "( #{visit o.left} UNION #{visit o.right} )" + end + + def visit_Arel_Nodes_UnionAll o + "( #{visit o.left} UNION ALL #{visit o.right} )" + end + def visit_Arel_Nodes_Having o "HAVING #{visit o.expr}" end |