-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
For an empty array, the default ends up looking like :default => '{}' in schema.rb, however, this doesn't get single-quoted when turned into a CREATE TABLE statement, causing rake db:schema:load to fail.
The following patch fixes it for string arrays, by causing it to be encoded in schema.rb as :default => [] and could probably be generalized:
require 'active_record/connection_adapters/postgresql_adapter'
module ConnectionAdapters
class PostgreSQLColumn < Column
class << self
def extract_value_from_default_with_array(default)
case default
when NilClass
nil
# Arrays
when /\A'(.*)'::"?character varying.*"?\[\]\z/
$1.from_postgres_array(:string)
else
extract_value_from_default_without_array(default)
end
end
alias_method_chain :extract_value_from_default, :array
end
end
endMetadata
Metadata
Assignees
Labels
No labels