aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-03 23:59:12 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-03 23:59:12 -0300
commit5777f0bff99b1c887626c84ef6124adfa5f14645 (patch)
tree91c704a2007260fff88c2eb6ca5ea399f8fffab1 /activerecord/lib
parent217e5f6e4a9d1764bc511ca095bbb15a63bb3b19 (diff)
parent3225ebfa0632cd42a0fbcf0cbca36c7c06e54844 (diff)
downloadrails-5777f0bff99b1c887626c84ef6124adfa5f14645.tar.gz
rails-5777f0bff99b1c887626c84ef6124adfa5f14645.tar.bz2
rails-5777f0bff99b1c887626c84ef6124adfa5f14645.zip
Merge pull request #18283 from kamipo/refactor_postgresql_column
Prefer `array?` rather than `array`
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/column.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/column.rb9
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb2
3 files changed, 7 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb
index af307b57a4..65d8b1a8ab 100644
--- a/activerecord/lib/active_record/connection_adapters/column.rb
+++ b/activerecord/lib/active_record/connection_adapters/column.rb
@@ -30,13 +30,13 @@ module ActiveRecord
# <tt>company_name varchar(60)</tt>.
# It will be mapped to one of the standard Rails SQL types in the <tt>type</tt> attribute.
# +null+ determines if this column allows +NULL+ values.
- def initialize(name, default, cast_type, sql_type = nil, null = true)
+ def initialize(name, default, cast_type, sql_type = nil, null = true, default_function = nil)
@name = name
@cast_type = cast_type
@sql_type = sql_type
@null = null
@default = default
- @default_function = nil
+ @default_function = default_function
end
def has_default?
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/column.rb b/activerecord/lib/active_record/connection_adapters/postgresql/column.rb
index 1458fbf496..acb1278499 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/column.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/column.rb
@@ -2,18 +2,17 @@ module ActiveRecord
module ConnectionAdapters
# PostgreSQL-specific extensions to column definitions in a table.
class PostgreSQLColumn < Column #:nodoc:
- attr_accessor :array
+ attr_reader :array
+ alias :array? :array
def initialize(name, default, cast_type, sql_type = nil, null = true, default_function = nil)
if sql_type =~ /\[\]$/
@array = true
- super(name, default, cast_type, sql_type[0..sql_type.length - 3], null)
+ sql_type = sql_type[0..sql_type.length - 3]
else
@array = false
- super(name, default, cast_type, sql_type, null)
end
-
- @default_function = default_function
+ super
end
def serial?
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 13bb5c187e..5b070cae4f 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -144,7 +144,7 @@ module ActiveRecord
# AbstractAdapter
def prepare_column_options(column) # :nodoc:
spec = super
- spec[:array] = 'true' if column.respond_to?(:array) && column.array
+ spec[:array] = 'true' if column.array?
spec[:default] = "\"#{column.default_function}\"" if column.default_function
spec
end