diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-24 16:26:09 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-24 16:26:09 -0700 |
commit | 93d72131bcc24ccb5536bec672d2dac94f8de651 (patch) | |
tree | b0bddcce28817906b483c8f73c574d350ac844c4 /lib/arel/visitors | |
parent | 24995298face1d08ffb52f6c1b0374feeb7a380b (diff) | |
download | rails-93d72131bcc24ccb5536bec672d2dac94f8de651.tar.gz rails-93d72131bcc24ccb5536bec672d2dac94f8de651.tar.bz2 rails-93d72131bcc24ccb5536bec672d2dac94f8de651.zip |
add the casting node to the AST at build time
If we add the casting node to the ast at build time, then we can avoid
doing the lookup at visit time.
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/mysql.rb | 4 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 40 |
2 files changed, 29 insertions, 15 deletions
diff --git a/lib/arel/visitors/mysql.rb b/lib/arel/visitors/mysql.rb index 4db5a94019..ec9d91f8ce 100644 --- a/lib/arel/visitors/mysql.rb +++ b/lib/arel/visitors/mysql.rb @@ -32,7 +32,9 @@ module Arel # :'( # http://dev.mysql.com/doc/refman/5.0/en/select.html#id3482214 def visit_Arel_Nodes_SelectStatement o, a - o.limit = Arel::Nodes::Limit.new(18446744073709551615) if o.offset && !o.limit + if o.offset && !o.limit + o.limit = Arel::Nodes::Limit.new(Nodes.build_quoted(18446744073709551615)) + end super end diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 236f0354b1..69c82e792a 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -116,6 +116,14 @@ module Arel o.alias ? " AS #{visit o.alias, a}" : ''}" end + def visit_Arel_Nodes_Casted o, a + quoted o.val, o.attribute + end + + def visit_Arel_Nodes_Quoted o, a + quoted o.expr, nil + end + def visit_Arel_Nodes_True o, a "TRUE" end @@ -562,20 +570,24 @@ module Arel quote(o, column_for(a)) end - alias :visit_ActiveSupport_Multibyte_Chars :quoted - alias :visit_ActiveSupport_StringInquirer :quoted - alias :visit_BigDecimal :quoted - alias :visit_Class :quoted - alias :visit_Date :quoted - alias :visit_DateTime :quoted - alias :visit_FalseClass :quoted - alias :visit_Float :quoted - alias :visit_Hash :quoted - alias :visit_NilClass :quoted - alias :visit_String :quoted - alias :visit_Symbol :quoted - alias :visit_Time :quoted - alias :visit_TrueClass :quoted + def unsupported o, a + raise "unsupported: #{o.class.name}" + end + + alias :visit_ActiveSupport_Multibyte_Chars :unsupported + alias :visit_ActiveSupport_StringInquirer :unsupported + alias :visit_BigDecimal :unsupported + alias :visit_Class :unsupported + alias :visit_Date :unsupported + alias :visit_DateTime :unsupported + alias :visit_FalseClass :unsupported + alias :visit_Float :unsupported + alias :visit_Hash :unsupported + alias :visit_NilClass :unsupported + alias :visit_String :unsupported + alias :visit_Symbol :unsupported + alias :visit_Time :unsupported + alias :visit_TrueClass :unsupported def visit_Arel_Nodes_InfixOperation o, a "#{visit o.left, a} #{o.operator} #{visit o.right, a}" |