QNester QNester - 8 months ago 103
Ruby Question

Sequel and Postgres array of enum

I have

enum_cars
.

I have table
user
with column:
own_cars: enum_cars[]


When I get User model and fetch
own_cars
field for instance, I have:

user.own_cars #=> "{Ford}" String


I connected


DB.extension :pg_array


and


Sequel.extension :pg_array


But this doesn't work for me. What I should do to fetch field as
Array
? Or it's impossible with enum array?

Answer Source

Resolve this problem.

If you have in table array enum field u should registrate array type:

DB.extension :pg_array
DB.register_array_type(:enum_cars)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download