aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-05-28 18:23:00 -0700
committerSean Griffin <sean@thoughtbot.com>2014-05-28 18:23:00 -0700
commit98a7dde064172dbf9b9c441175fcd45dca70d8db (patch)
tree0419718eddb19016b754f81e9ca2f2baff0f7281 /activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
parent37c7774504f29fcb99362a1983c1364c856e116e (diff)
downloadrails-98a7dde064172dbf9b9c441175fcd45dca70d8db.tar.gz
rails-98a7dde064172dbf9b9c441175fcd45dca70d8db.tar.bz2
rails-98a7dde064172dbf9b9c441175fcd45dca70d8db.zip
Ensure we always use instances of the adapter specific column class
- Create a consistent API across adapters for building new columns - Use it for custom properties so we don't get `UndefinedMethodError`s in stuff I'm implementing elsewhere.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
index 484c44dc8d..b4d53eba26 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -181,10 +181,14 @@ module ActiveRecord
oid = get_oid_type(oid.to_i, fmod.to_i, column_name, type)
default_value = extract_value_from_default(default)
default_function = extract_default_function(default_value, default)
- PostgreSQLColumn.new(column_name, default_value, oid, type, notnull == 'f', default_function)
+ new_column(column_name, default_value, oid, type, notnull == 'f', default_function)
end
end
+ def new_column(name, default, cast_type, sql_type = nil, null = true, default_function = nil) # :nodoc:
+ PostgreSQLColumn.new(name, default, cast_type, sql_type, null, default_function)
+ end
+
# Returns the current database name.
def current_database
query('select current_database()', 'SCHEMA')[0][0]