Open caleb opened 4 years ago
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[].
enum[]
Everything works fine if I convert the column into a string[], and the enum[] type works in MRI with the pg gem.
string[]
pg
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:
method [] does not exist on type NilClass
ExpenseType
>> 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
coding_restriction
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 theenum[]
type works in MRI with thepg
gem.Here is how I created the column:
I get an error that
method [] does not exist on type NilClass
whenever I try to use myExpenseType
class: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