mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove deprecated Arel::SqlLiteral
This commit is contained in:
parent
f4ab6a39be
commit
a7d06943dd
9 changed files with 15 additions and 27 deletions
|
@ -24,11 +24,6 @@ require 'arel/update_manager'
|
|||
require 'arel/delete_manager'
|
||||
require 'arel/nodes'
|
||||
|
||||
|
||||
#### these are deprecated
|
||||
require 'arel/sql_literal'
|
||||
####
|
||||
|
||||
module Arel
|
||||
VERSION = '5.0.0'
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Arel
|
|||
return if fields.empty?
|
||||
|
||||
if String === fields
|
||||
@ast.values = SqlLiteral.new(fields)
|
||||
@ast.values = Nodes::SqlLiteral.new(fields)
|
||||
else
|
||||
@ast.relation ||= fields.first.first.relation
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ module Arel
|
|||
# FIXME: converting these to SQLLiterals is probably not good, but
|
||||
# rails tests require it.
|
||||
@ctx.projections.concat projections.map { |x|
|
||||
STRING_OR_SYMBOL_CLASS.include?(x.class) ? SqlLiteral.new(x.to_s) : x
|
||||
STRING_OR_SYMBOL_CLASS.include?(x.class) ? Nodes::SqlLiteral.new(x.to_s) : x
|
||||
}
|
||||
self
|
||||
end
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
module Arel
|
||||
class SqlLiteral < Nodes::SqlLiteral
|
||||
end
|
||||
end
|
|
@ -112,7 +112,6 @@ module Arel
|
|||
alias :visit_Arel_Nodes_SqlLiteral :terminal
|
||||
alias :visit_Arel_Nodes_BindParam :terminal
|
||||
alias :visit_Arel_Nodes_Window :terminal
|
||||
alias :visit_Arel_SqlLiteral :terminal
|
||||
alias :visit_BigDecimal :terminal
|
||||
alias :visit_Bignum :terminal
|
||||
alias :visit_Class :terminal
|
||||
|
|
|
@ -193,7 +193,6 @@ module Arel
|
|||
alias :visit_NilClass :visit_String
|
||||
alias :visit_TrueClass :visit_String
|
||||
alias :visit_FalseClass :visit_String
|
||||
alias :visit_Arel_SqlLiteral :visit_String
|
||||
alias :visit_Arel_Nodes_BindParam :visit_String
|
||||
alias :visit_Fixnum :visit_String
|
||||
alias :visit_BigDecimal :visit_String
|
||||
|
|
|
@ -550,7 +550,6 @@ module Arel
|
|||
|
||||
alias :visit_Arel_Nodes_BindParam :literal
|
||||
alias :visit_Arel_Nodes_SqlLiteral :literal
|
||||
alias :visit_Arel_SqlLiteral :literal # This is deprecated
|
||||
alias :visit_Bignum :literal
|
||||
alias :visit_Fixnum :literal
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ module Arel
|
|||
it 'accepts symbols' do
|
||||
table = Table.new :users
|
||||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.project SqlLiteral.new '*'
|
||||
manager.project Nodes::SqlLiteral.new '*'
|
||||
manager.from table
|
||||
manager.order :foo
|
||||
manager.to_sql.must_be_like %{ SELECT * FROM "users" ORDER BY foo }
|
||||
|
@ -224,7 +224,7 @@ module Arel
|
|||
it 'should create an exists clause' do
|
||||
table = Table.new(:users)
|
||||
manager = Arel::SelectManager.new Table.engine, table
|
||||
manager.project SqlLiteral.new '*'
|
||||
manager.project Nodes::SqlLiteral.new '*'
|
||||
m2 = Arel::SelectManager.new(manager.engine)
|
||||
m2.project manager.exists
|
||||
m2.to_sql.must_be_like %{ SELECT EXISTS (#{manager.to_sql}) }
|
||||
|
@ -233,7 +233,7 @@ module Arel
|
|||
it 'can be aliased' do
|
||||
table = Table.new(:users)
|
||||
manager = Arel::SelectManager.new Table.engine, table
|
||||
manager.project SqlLiteral.new '*'
|
||||
manager.project Nodes::SqlLiteral.new '*'
|
||||
m2 = Arel::SelectManager.new(manager.engine)
|
||||
m2.project manager.exists.as('foo')
|
||||
m2.to_sql.must_be_like %{ SELECT EXISTS (#{manager.to_sql}) AS foo }
|
||||
|
@ -413,7 +413,7 @@ module Arel
|
|||
it 'generates order clauses' do
|
||||
table = Table.new :users
|
||||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.project SqlLiteral.new '*'
|
||||
manager.project Nodes::SqlLiteral.new '*'
|
||||
manager.from table
|
||||
manager.order table[:id]
|
||||
manager.to_sql.must_be_like %{
|
||||
|
@ -425,7 +425,7 @@ module Arel
|
|||
it 'takes *args' do
|
||||
table = Table.new :users
|
||||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.project SqlLiteral.new '*'
|
||||
manager.project Nodes::SqlLiteral.new '*'
|
||||
manager.from table
|
||||
manager.order table[:id], table[:name]
|
||||
manager.to_sql.must_be_like %{
|
||||
|
@ -442,7 +442,7 @@ module Arel
|
|||
it 'has order attributes' do
|
||||
table = Table.new :users
|
||||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.project SqlLiteral.new '*'
|
||||
manager.project Nodes::SqlLiteral.new '*'
|
||||
manager.from table
|
||||
manager.order table[:id].desc
|
||||
manager.to_sql.must_be_like %{
|
||||
|
@ -453,7 +453,7 @@ module Arel
|
|||
it 'has order attributes for expressions' do
|
||||
table = Table.new :users
|
||||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.project SqlLiteral.new '*'
|
||||
manager.project Nodes::SqlLiteral.new '*'
|
||||
manager.from table
|
||||
manager.order table[:id].count.desc
|
||||
manager.to_sql.must_be_like %{
|
||||
|
@ -873,7 +873,7 @@ module Arel
|
|||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.from table
|
||||
manager.take 1
|
||||
stmt = manager.compile_update(SqlLiteral.new('foo = bar'), Arel::Attributes::Attribute.new(table, 'id'))
|
||||
stmt = manager.compile_update(Nodes::SqlLiteral.new('foo = bar'), Arel::Attributes::Attribute.new(table, 'id'))
|
||||
stmt.key = table['id']
|
||||
|
||||
stmt.to_sql.must_be_like %{
|
||||
|
@ -887,7 +887,7 @@ module Arel
|
|||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.from table
|
||||
manager.order :foo
|
||||
stmt = manager.compile_update(SqlLiteral.new('foo = bar'), Arel::Attributes::Attribute.new(table, 'id'))
|
||||
stmt = manager.compile_update(Nodes::SqlLiteral.new('foo = bar'), Arel::Attributes::Attribute.new(table, 'id'))
|
||||
stmt.key = table['id']
|
||||
|
||||
stmt.to_sql.must_be_like %{
|
||||
|
@ -900,7 +900,7 @@ module Arel
|
|||
table = Table.new :users
|
||||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.from table
|
||||
stmt = manager.compile_update(SqlLiteral.new('foo = bar'), Arel::Attributes::Attribute.new(table, 'id'))
|
||||
stmt = manager.compile_update(Nodes::SqlLiteral.new('foo = bar'), Arel::Attributes::Attribute.new(table, 'id'))
|
||||
|
||||
stmt.to_sql.must_be_like %{ UPDATE "users" SET foo = bar }
|
||||
end
|
||||
|
|
|
@ -130,19 +130,19 @@ module Arel
|
|||
describe 'take' do
|
||||
it "should add a limit" do
|
||||
manager = @relation.take 1
|
||||
manager.project SqlLiteral.new '*'
|
||||
manager.project Nodes::SqlLiteral.new '*'
|
||||
manager.to_sql.must_be_like %{ SELECT * FROM "users" LIMIT 1 }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'project' do
|
||||
it 'can project' do
|
||||
manager = @relation.project SqlLiteral.new '*'
|
||||
manager = @relation.project Nodes::SqlLiteral.new '*'
|
||||
manager.to_sql.must_be_like %{ SELECT * FROM "users" }
|
||||
end
|
||||
|
||||
it 'takes multiple parameters' do
|
||||
manager = @relation.project SqlLiteral.new('*'), SqlLiteral.new('*')
|
||||
manager = @relation.project Nodes::SqlLiteral.new('*'), Nodes::SqlLiteral.new('*')
|
||||
manager.to_sql.must_be_like %{ SELECT *, * FROM "users" }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue