diff options
author | Ernie Miller <ernie@metautonomo.us> | 2011-04-29 13:36:22 -0400 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-29 11:13:41 -0700 |
commit | 7361b6cbd5e4c6f03198ed42eed4e3dd4feb149e (patch) | |
tree | fdc15b45bcc57407e7192ba2e9db537ad871b94e /lib | |
parent | d09a882329e8eeebac89e907289c537077f81d44 (diff) | |
download | rails-7361b6cbd5e4c6f03198ed42eed4e3dd4feb149e.tar.gz rails-7361b6cbd5e4c6f03198ed42eed4e3dd4feb149e.tar.bz2 rails-7361b6cbd5e4c6f03198ed42eed4e3dd4feb149e.zip |
Move #as to AliasPredication, stop overriding Function's #as.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel.rb | 1 | ||||
-rw-r--r-- | lib/arel/alias_predication.rb | 7 | ||||
-rw-r--r-- | lib/arel/attributes/attribute.rb | 1 | ||||
-rw-r--r-- | lib/arel/nodes/function.rb | 4 | ||||
-rw-r--r-- | lib/arel/nodes/infix_operation.rb | 1 | ||||
-rw-r--r-- | lib/arel/nodes/sql_literal.rb | 1 | ||||
-rw-r--r-- | lib/arel/predications.rb | 4 |
7 files changed, 13 insertions, 6 deletions
diff --git a/lib/arel.rb b/lib/arel.rb index bc599514e2..ff43de2067 100644 --- a/lib/arel.rb +++ b/lib/arel.rb @@ -4,6 +4,7 @@ require 'arel/factory_methods' require 'arel/expressions' require 'arel/predications' require 'arel/math' +require 'arel/alias_predication' require 'arel/order_predications' require 'arel/table' require 'arel/attributes' diff --git a/lib/arel/alias_predication.rb b/lib/arel/alias_predication.rb new file mode 100644 index 0000000000..3f3db7671e --- /dev/null +++ b/lib/arel/alias_predication.rb @@ -0,0 +1,7 @@ +module Arel + module AliasPredication + def as other + Nodes::As.new self, Nodes::SqlLiteral.new(other.to_s) + end + end +end
\ No newline at end of file diff --git a/lib/arel/attributes/attribute.rb b/lib/arel/attributes/attribute.rb index b9fd8da67e..0906fa4f1d 100644 --- a/lib/arel/attributes/attribute.rb +++ b/lib/arel/attributes/attribute.rb @@ -3,6 +3,7 @@ module Arel class Attribute < Struct.new :relation, :name include Arel::Expressions include Arel::Predications + include Arel::AliasPredication include Arel::OrderPredications include Arel::Math diff --git a/lib/arel/nodes/function.rb b/lib/arel/nodes/function.rb index b58eba7f38..3263ff9cd4 100644 --- a/lib/arel/nodes/function.rb +++ b/lib/arel/nodes/function.rb @@ -6,12 +6,12 @@ module Arel def initialize expr, aliaz = nil @expressions = expr - @alias = aliaz + @alias = aliaz && SqlLiteral.new(aliaz.to_s) @distinct = false end def as aliaz - self.alias = SqlLiteral.new(aliaz) + self.alias = SqlLiteral.new(aliaz.to_s) self end end diff --git a/lib/arel/nodes/infix_operation.rb b/lib/arel/nodes/infix_operation.rb index 6847650fe4..75879ce43f 100644 --- a/lib/arel/nodes/infix_operation.rb +++ b/lib/arel/nodes/infix_operation.rb @@ -4,6 +4,7 @@ module Arel class InfixOperation < Binary include Arel::Expressions include Arel::Predications + include Arel::AliasPredication include Arel::Math attr_reader :operator diff --git a/lib/arel/nodes/sql_literal.rb b/lib/arel/nodes/sql_literal.rb index ad0bb00484..2e934b2a1b 100644 --- a/lib/arel/nodes/sql_literal.rb +++ b/lib/arel/nodes/sql_literal.rb @@ -3,6 +3,7 @@ module Arel class SqlLiteral < String include Arel::Expressions include Arel::Predications + include Arel::AliasPredication include Arel::OrderPredications end end diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb index 08cbf16d9d..4b124ce05c 100644 --- a/lib/arel/predications.rb +++ b/lib/arel/predications.rb @@ -1,10 +1,6 @@ module Arel module Predications - def as other - Nodes::As.new self, Nodes::SqlLiteral.new(other) - end - def not_eq other Nodes::NotEqual.new self, other end |