Columns defined with default: [], array: true show as { } instead?
1990eam opened this issue · 1 comments
I'm sorry if this is not a bug but I couldn't find the corresponding section in the docs.
ruby 2.7.6
rails 6.0.4.7
I created a new table with a single column of type text
, default: []
and array: true
def change
create_table :foo do |t|
t.text :bar, array: true, default: []
end
end
schema.rb
shows the right information:
create_table "foo", force: :cascade do |t|
t.text "bar", default: [], array: true
end
Blazer schema shows:
foos
bar | ARRAY
But in Blazer the queried column shows as {}
when empty instead of []
.
When populated, instead of showing as an array of strings ["value1", "value2"]
it shows as {value1, value2}
.
The same query using ActiveRecord methods via console returns the right format for the stored data:
foo = Foo.first
foo.bar
=> ["value1", "value2"]
Is this a bug or intentional?
Hey @1990eam, arrays in Postgres use curly braces, which is why it's showing up that way. Active Record is deserializing it to a Ruby array in the example above. However, I'm hesitant to make the output Ruby-specific.