aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/table.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/table.rb')
-rw-r--r--lib/arel/table.rb46
1 files changed, 28 insertions, 18 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb
index aa23a7d601..d1d1e40e11 100644
--- a/lib/arel/table.rb
+++ b/lib/arel/table.rb
@@ -1,6 +1,7 @@
module Arel
class Table
include Arel::Crud
+ include Arel::FactoryMethods
@engine = nil
class << self; attr_accessor :engine; end
@@ -17,7 +18,6 @@ module Arel
if Hash === engine
@engine = engine[:engine] || Table.engine
- @columns = attributes_for engine[:columns]
# Sometime AR sends an :as parameter to table, to let the table know
# that it is an Alias. We may want to override new, and return a
@@ -27,6 +27,11 @@ module Arel
end
def primary_key
+ if $VERBOSE
+ warn <<-eowarn
+primary_key (#{caller.first}) is deprecated and will be removed in ARel 3.0.0
+ eowarn
+ end
@primary_key ||= begin
primary_key_name = @engine.connection.primary_key(name)
# some tables might be without primary key
@@ -46,7 +51,7 @@ module Arel
def joins manager
if $VERBOSE
- warn "joins is deprecated and will be removed in 2.2"
+ warn "joins is deprecated and will be removed in 3.0.0"
warn "please remove your call to joins from #{caller.first}"
end
nil
@@ -58,10 +63,10 @@ module Arel
case relation
when String, Nodes::SqlLiteral
raise if relation.blank?
- from Nodes::StringJoin.new(self, relation)
- else
- from klass.new(self, relation, nil)
+ klass = Nodes::StringJoin
end
+
+ from(self).join(relation, klass)
end
def group *columns
@@ -93,41 +98,46 @@ module Arel
end
def columns
+ if $VERBOSE
+ warn <<-eowarn
+(#{caller.first}) Arel::Table#columns is deprecated and will be removed in
+Arel 3.0.0 with no replacement. PEW PEW PEW!!!
+ eowarn
+ end
@columns ||=
attributes_for @engine.connection.columns(@name, "#{@name} Columns")
end
def [] name
- return nil unless table_exists?
-
- name = name.to_sym
- columns.find { |column| column.name == name }
+ ::Arel::Attribute.new self, name
end
def select_manager
SelectManager.new(@engine)
end
+ def insert_manager
+ InsertManager.new(@engine)
+ end
+
private
def attributes_for columns
return nil unless columns
columns.map do |column|
- Attributes.for(column).new self, column.name.to_sym, column
+ Attributes.for(column).new self, column.name.to_sym
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 3.0.0 with no replacement. PEW PEW PEW!!!
+ eowarn
+ end
@@table_cache ||= Hash[engine.connection.tables.map { |x| [x,true] }]
end
end