Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Columns that have an enum[] type cause an error with PostgreSQL #1070

Open
caleb opened this issue Sep 3, 2020 · 0 comments
Open

Columns that have an enum[] type cause an error with PostgreSQL #1070

caleb opened this issue Sep 3, 2020 · 0 comments

Comments

@caleb
Copy link

caleb commented Sep 3, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant