diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb index 920a9ee374..75c4c75855 100644 --- a/lib/arel/predications.rb +++ b/lib/arel/predications.rb @@ -1,7 +1,7 @@ module Arel module Predications def as other - Nodes::As.new self, other + Nodes::As.new self, Nodes::SqlLiteral.new(other) end def not_eq other diff --git a/test/nodes/test_as.rb b/test/nodes/test_as.rb index 8585fbc963..02cbe5f7b0 100644 --- a/test/nodes/test_as.rb +++ b/test/nodes/test_as.rb @@ -10,6 +10,12 @@ module Arel assert_equal attr, as.left assert_equal 'foo', as.right end + + it 'converts right to SqlLiteral if a string' do + attr = Table.new(:users)[:id] + as = attr.as('foo') + assert_kind_of Arel::Nodes::SqlLiteral, as.right + end end end end