activerecord-jdbc-adapter
activerecord-jdbc-adapter copied to clipboard
Columns that have an enum[] type cause an error with PostgreSQL
I have a Rails 6 application that I'm testing JRuby with and I ran into an issue with a column in PostgreSQL (9.6) that has a type enum[].
Everything works fine if I convert the column into a string[], and the enum[] type works in MRI with the pg gem.
Here is how I created the column:
execute <<-SQL
CREATE TYPE coding_restriction AS ENUM ('corporate', 'owner', 'unit');
SQL
add_column :expense_types, :coding_restrictions, :coding_restriction, default: '{}', array: true, null: false
I get an error that method [] does not exist on type NilClass whenever I try to use my ExpenseType class:
>> reload! && ExpenseType.first
Reloading...
Traceback (most recent call last):
1: from (irb):2:in `evaluate'
ActiveRecord::StatementInvalid (NoMethodError: undefined method `[]' for nil:NilClass)
>>
That's the entire stack trace :)
EDIT:
I should add that I have another table with a column with the same enum type (coding_restriction) that works fine, presumably because it's not an array