diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-15 19:34:20 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-22 16:21:59 -0700 |
commit | cd07f194dc2d8e4278ea9a7d4ccebfe74513b0ac (patch) | |
tree | 59dbe54c54ed1674c50a86b25201f33ab9f0ae95 /activerecord/lib | |
parent | 4b4c8bdc776e2d42cd070d9cb1b3cc22f82469b1 (diff) | |
download | rails-cd07f194dc2d8e4278ea9a7d4ccebfe74513b0ac.tar.gz rails-cd07f194dc2d8e4278ea9a7d4ccebfe74513b0ac.tar.bz2 rails-cd07f194dc2d8e4278ea9a7d4ccebfe74513b0ac.zip |
decouple column definition from the database connection
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 12 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 4642d6a0c7..952b872f7a 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -15,7 +15,7 @@ module ActiveRecord # are typically created by methods in TableDefinition, and added to the # +columns+ attribute of said TableDefinition object, in order to be used # for generating a number of table creation or table changing SQL statements. - class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :precision, :scale, :default, :null) #:nodoc: + class ColumnDefinition < Struct.new(:name, :type, :limit, :precision, :scale, :default, :null) #:nodoc: def string_to_binary(value) value end @@ -213,7 +213,7 @@ module ActiveRecord raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table." end - column = self[name] || new_column_definition(@base, name, type) + column = self[name] || new_column_definition(name, type) limit = options.fetch(:limit) do native[type][:limit] if native[type].is_a?(Hash) @@ -272,12 +272,12 @@ module ActiveRecord end private - def create_column_definition(base, name, type) - ColumnDefinition.new base, name, type + def create_column_definition(name, type) + ColumnDefinition.new name, type end - def new_column_definition(base, name, type) - definition = create_column_definition base, name, type + def new_column_definition(name, type) + definition = create_column_definition name, type @columns << definition @columns_hash[name] = definition definition diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 940de7e4f6..48a3d5439f 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -344,8 +344,8 @@ module ActiveRecord private - def create_column_definition(base, name, type) - ColumnDefinition.new base, name, type + def create_column_definition(name, type) + ColumnDefinition.new name, type end end |