aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel')
-rw-r--r--lib/arel/alias_predication.rb7
-rw-r--r--lib/arel/attributes/attribute.rb1
-rw-r--r--lib/arel/nodes/function.rb4
-rw-r--r--lib/arel/nodes/infix_operation.rb1
-rw-r--r--lib/arel/nodes/sql_literal.rb1
-rw-r--r--lib/arel/predications.rb4
6 files changed, 12 insertions, 6 deletions
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