You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
end
The text was updated successfully, but these errors were encountered:
For an empty array, the default ends up looking like
:default => '{}'
in schema.rb, however, this doesn't get single-quoted when turned into aCREATE TABLE
statement, causingrake 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:The text was updated successfully, but these errors were encountered: