From 8a5680e4a75eb6ac877c1c9687a99e021cbba74e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 3 Dec 2010 16:01:36 -0800 Subject: declawing connection from the Table class --- lib/arel/table.rb | 18 ++++++++---------- lib/arel/visitors/to_sql.rb | 9 +++++---- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'lib/arel') diff --git a/lib/arel/table.rb b/lib/arel/table.rb index c2db388fd4..79c9b60945 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -94,8 +94,8 @@ module Arel def columns if $VERBOSE warn <<-eowarn -(#{caller.first}) Arel::Table#columns is deprecated and will be removed in -Arel 2.2.0 with no replacement. +(#{caller.first}) Arel::Table#columns is deprecated and will be removed in +Arel 2.2.0 with no replacement. PEW PEW PEW!!! eowarn end @columns ||= @@ -124,16 +124,14 @@ Arel 2.2.0 with no replacement. end end - def table_exists? - @table_exists ||= tables.key?(@name) || engine.connection.table_exists?(name) - end - - def tables - self.class.table_cache(@engine) - end - @@table_cache = nil def self.table_cache engine # :nodoc: + if $VERBOSE + warn <<-eowarn +(#{caller.first}) Arel::Table.table_cache is deprecated and will be removed in +Arel 2.2.0 with no replacement. PEW PEW PEW!!! + eowarn + end @@table_cache ||= Hash[engine.connection.tables.map { |x| [x,true] }] end end diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 8db90c376a..082196ef2b 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -70,11 +70,12 @@ module Arel def table_exists? name return true if @table_exists.key? name - if @connection.table_exists?(name) - @table_exists[name] = true - else - false + + @connection.tables.each do |table| + @table_exists[table] = true end + + @table_exists.key? name end def column_for attr -- cgit v1.2.3