diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-03 10:31:25 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-03 10:31:25 -0800 |
commit | d4259c5ce2f6b05226a8b934537678ade1606e97 (patch) | |
tree | 9059008ad935fcf93e979a3b057e1fdc19994dc9 /lib/arel/visitors/to_sql.rb | |
parent | cefad1e2139c4bba6e45f3281a6d54394aaeb366 (diff) | |
parent | 1215c28311aab325c55c083d15cbf3e16599d502 (diff) | |
download | rails-d4259c5ce2f6b05226a8b934537678ade1606e97.tar.gz rails-d4259c5ce2f6b05226a8b934537678ade1606e97.tar.bz2 rails-d4259c5ce2f6b05226a8b934537678ade1606e97.zip |
Merge branch '2-0-stable' into merge
* 2-0-stable:
updating history
Patched Arel v2.0.6 to support MSSQL SQL queries. Based on work of James Abley (https://github.com/jabley/arel).
consolidating dot visitor methods
refactoring where, fixing subselect
implementation for passing a subquery to #in and #not_in
tests for passing a subquery to #in and #not_in
limit members of the AST are visited
quoting limit nodes
Conflicts:
History.txt
lib/arel/nodes.rb
lib/arel/nodes/select_core.rb
lib/arel/select_manager.rb
lib/arel/visitors/to_sql.rb
test/visitors/test_to_sql.rb
Diffstat (limited to 'lib/arel/visitors/to_sql.rb')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index f25c0ee69f..9830e559d5 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -131,7 +131,7 @@ eowarn [ o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join, ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?), - ("LIMIT #{visit o.limit}" if o.limit), + (visit(o.limit) if o.limit), (visit(o.offset) if o.offset), (visit(o.lock) if o.lock), ].compact.join ' ' @@ -139,7 +139,9 @@ eowarn def visit_Arel_Nodes_SelectCore o [ - "SELECT #{o.projections.map { |x| visit x }.join ', '}", + "SELECT", + (visit(o.top) if o.top), + "#{o.projections.map { |x| visit x }.join ', '}", visit(o.source), ("WHERE #{o.wheres.map { |x| visit x }.join ' AND ' }" unless o.wheres.empty?), ("GROUP BY #{o.groups.map { |x| visit x }.join ', ' }" unless o.groups.empty?), @@ -155,6 +157,15 @@ eowarn "OFFSET #{visit o.expr}" end + def visit_Arel_Nodes_Limit o + "LIMIT #{visit o.expr}" + end + + # FIXME: this does nothing on most databases, but does on MSSQL + def visit_Arel_Nodes_Top o + "" + end + # FIXME: this does nothing on SQLLite3, but should do things on other # databases. def visit_Arel_Nodes_Lock o @@ -357,6 +368,10 @@ eowarn o.empty? ? 'NULL' : o.map { |x| visit x }.join(', ') end + def visit_Array o + o.empty? ? 'NULL' : o.map { |x| visit x }.join(', ') + end + def quote value, column = nil @connection.quote value, column end |