diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-11-10 16:50:43 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-11-10 16:50:43 -0800 |
commit | 03f51687e204f03cdf8d8395350d4d0514a7f620 (patch) | |
tree | fd353b7936bd77ca2c8b624c31cab6b650b74bca | |
parent | e0d3bcb6519faec69326a98413cb6d5406d9cb58 (diff) | |
parent | 9cbfc8a370bf6537a02a2f21e7246dc21ba4cf1f (diff) | |
download | rails-03f51687e204f03cdf8d8395350d4d0514a7f620.tar.gz rails-03f51687e204f03cdf8d8395350d4d0514a7f620.tar.bz2 rails-03f51687e204f03cdf8d8395350d4d0514a7f620.zip |
Merge pull request #198 from vipulnsward/deprecations
Deprecations
-rw-r--r-- | lib/arel/crud.rb | 34 | ||||
-rw-r--r-- | lib/arel/select_manager.rb | 38 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 12 | ||||
-rw-r--r-- | test/test_activerecord_compat.rb | 18 | ||||
-rw-r--r-- | test/test_select_manager.rb | 14 |
5 files changed, 2 insertions, 114 deletions
diff --git a/lib/arel/crud.rb b/lib/arel/crud.rb index e8e78a381c..ef14439a1f 100644 --- a/lib/arel/crud.rb +++ b/lib/arel/crud.rb @@ -10,6 +10,7 @@ module Arel else relation = values.first.first.relation end + um.key= relation.primary_key um.table relation um.set values um.take @ast.limit.expr if @ast.limit @@ -18,19 +19,6 @@ module Arel um end - # FIXME: this method should go away - def update values - if $VERBOSE - warn <<-eowarn -update (#{caller.first}) is deprecated and will be removed in Arel 4.0.0. Please -switch to `compile_update` - eowarn - end - - um = compile_update values - @engine.connection.update um.to_sql, 'AREL' - end - def compile_insert values im = create_insert im.insert values @@ -41,17 +29,6 @@ switch to `compile_update` InsertManager.new @engine end - # FIXME: this method should go away - def insert values - if $VERBOSE - warn <<-eowarn -insert (#{caller.first}) is deprecated and will be removed in Arel 4.0.0. Please -switch to `compile_insert` - eowarn - end - @engine.connection.insert compile_insert(values).to_sql - end - def compile_delete dm = DeleteManager.new @engine dm.wheres = @ctx.wheres @@ -59,14 +36,5 @@ switch to `compile_insert` dm end - def delete - if $VERBOSE - warn <<-eowarn -delete (#{caller.first}) is deprecated and will be removed in Arel 4.0.0. Please -switch to `compile_delete` - eowarn - end - @engine.connection.delete compile_delete.to_sql, 'AREL' - end end end diff --git a/lib/arel/select_manager.rb b/lib/arel/select_manager.rb index ee9d34a514..60df12c700 100644 --- a/lib/arel/select_manager.rb +++ b/lib/arel/select_manager.rb @@ -47,14 +47,6 @@ module Arel create_table_alias grouping(@ast), Nodes::SqlLiteral.new(other) end - def where_clauses - if $VERBOSE - warn "(#{caller.first}) where_clauses is deprecated and will be removed in arel 4.0.0 with no replacement" - end - to_sql = Visitors::ToSql.new @engine.connection - @ctx.wheres.map { |c| to_sql.accept c } - end - def lock locking = Arel.sql('FOR UPDATE') case locking when true @@ -169,11 +161,6 @@ module Arel @ast.orders end - def wheres - warn "#{caller[0]}: SelectManager#wheres is deprecated and will be removed in Arel 4.0.0 with no replacement" - Compatibility::Wheres.new @engine.connection, @ctx.wheres - end - def where_sql return if @ctx.wheres.empty? @@ -272,31 +259,6 @@ module Arel @engine.connection.send(:select, to_sql, 'AREL').map { |x| Row.new(x) } end - # FIXME: this method should go away - def insert values - if $VERBOSE - warn <<-eowarn -insert (#{caller.first}) is deprecated and will be removed in Arel 4.0.0. Please -switch to `compile_insert` - eowarn - end - - im = compile_insert(values) - table = @ctx.froms - - primary_key = table.primary_key - primary_key_name = primary_key.name if primary_key - - # FIXME: in AR tests values sometimes were Array and not Hash therefore is_a?(Hash) check is added - primary_key_value = primary_key && values.is_a?(Hash) && values[primary_key] - im.into table - # Oracle adapter needs primary key name to generate RETURNING ... INTO ... clause - # for tables which assign primary key value using trigger. - # RETURNING ... INTO ... clause will be added only if primary_key_value is nil - # therefore it is necessary to pass primary key value as well - @engine.connection.insert im.to_sql, 'AREL', primary_key_name, primary_key_value - end - private def collapse exprs, existing = nil exprs = exprs.unshift(existing.expr) if existing diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index b61d5f7acd..1d8cd35806 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -85,17 +85,7 @@ module Arel if o.orders.empty? && o.limit.nil? wheres = o.wheres else - key = o.key - unless key - warn(<<-eowarn) if $VERBOSE -(#{caller.first}) Using UpdateManager without setting UpdateManager#key is -deprecated and support will be removed in Arel 4.0.0. Please set the primary -key on UpdateManager using UpdateManager#key= '#{key.inspect}' - eowarn - key = o.relation.primary_key - end - - wheres = [Nodes::In.new(key, [build_subselect(key, o)])] + wheres = [Nodes::In.new(o.key, [build_subselect(o.key, o)])] end [ diff --git a/test/test_activerecord_compat.rb b/test/test_activerecord_compat.rb deleted file mode 100644 index d881209610..0000000000 --- a/test/test_activerecord_compat.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'helper' - -module Arel - describe 'activerecord compatibility' do - describe 'select manager' do - it 'provides wheres' do - table = Table.new :users - manager = Arel::SelectManager.new Table.engine - manager.where table[:id].eq 1 - manager.where table[:name].eq 'Aaron' - - manager.wheres.map { |x| - x.value - }.join(', ').must_equal "\"users\".\"id\" = 1, \"users\".\"name\" = 'Aaron'" - end - end - end -end diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb index a449f78bd8..9779aca21d 100644 --- a/test/test_select_manager.rb +++ b/test/test_select_manager.rb @@ -435,20 +435,6 @@ module Arel end end - describe 'insert' do - it 'uses the select FROM' do - engine = EngineProxy.new Table.engine - table = Table.new :users - manager = Arel::SelectManager.new engine - manager.from table - manager.insert 'VALUES(NULL)' - - engine.executed.last.must_be_like %{ - INSERT INTO "users" VALUES(NULL) - } - end - end - describe 'lock' do # This should fail on other databases it 'adds a lock node' do |