diff options
author | Ernie Miller <ernie@metautonomo.us> | 2011-03-09 02:27:43 +0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-03-09 03:03:05 +0800 |
commit | 21e052796d3007488d5dd9f00299a3a22fdb6249 (patch) | |
tree | 10807b13b1af103dc961eeed5ce1a6ee73cde357 /lib/arel/visitors | |
parent | 2fc53bec29bb660e501cf350ae07506082dcb110 (diff) | |
download | rails-21e052796d3007488d5dd9f00299a3a22fdb6249.tar.gz rails-21e052796d3007488d5dd9f00299a3a22fdb6249.tar.bz2 rails-21e052796d3007488d5dd9f00299a3a22fdb6249.zip |
Replace MathOperation with InfixOperation to support more operators
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index f30557e509..1550757cf4 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -373,21 +373,14 @@ key on UpdateManager using UpdateManager#key= alias :visit_Time :quoted alias :visit_TrueClass :quoted - def visit_Arel_Nodes_Multiplication o - "#{visit o.left} * #{visit o.right}" + def visit_Arel_Nodes_InfixOperation o + "#{visit o.left} #{o.operator} #{visit o.right}" end - def visit_Arel_Nodes_Division o - "#{visit o.left} / #{visit o.right}" - end - - def visit_Arel_Nodes_Addition o - "(#{visit o.left} + #{visit o.right})" - end - - def visit_Arel_Nodes_Subtraction o - "(#{visit o.left} - #{visit o.right})" - end + alias :visit_Arel_Nodes_Addition :visit_Arel_Nodes_InfixOperation + alias :visit_Arel_Nodes_Subtraction :visit_Arel_Nodes_InfixOperation + alias :visit_Arel_Nodes_Multiplication :visit_Arel_Nodes_InfixOperation + alias :visit_Arel_Nodes_Division :visit_Arel_Nodes_InfixOperation def visit_Array o o.empty? ? 'NULL' : o.map { |x| visit x }.join(', ') |