I want to create a Sequel::Model that has an array attribute. I have added a varchar[] column to the table, and I can successfully update records using Sequel::Dataset::update. However, if I try to set the attribute on a model instance and save it, I get an error:
2.1.1 :048 > a = Sequel.pg_array(['public'])
=> ["public"]
2.1.1 :049 > DB[:oauth_access_tokens].where(id: 1).update(scopes: a)
I, [2014-06-19T09:53:49.009563 #40260] INFO -- : (0.003404s) UPDATE "oauth_access_tokens" SET "scopes" = ARRAY['public'] WHERE ("id" = 1)
=> 1
2.1.1 :050 > token = AccessToken.find(id: 1)
I, [2014-06-19T09:53:52.438038 #40260] INFO -- : (0.000771s) SELECT * FROM "oauth_access_tokens" WHERE ("id" = 1) LIMIT 1
=> #<AccessToken @values={:id=>1, :resource_owner_id=>2, :application_id=>1, :token=>"ec73426e2be81ab4772e67e139430d3896d705bcee6c141a38bd0e903e5df3eb", :refresh_token=>nil, :expires_in=>7200, :revoked_at=>nil, :created_at=>2014-06-06 12:37:07 -0400, :scopes=>["public"]}>
2.1.1 :051 > token.scopes = a
=> ["public"]
2.1.1 :052 > token.save
I, [2014-06-19T09:54:02.261076 #40260] INFO -- : (0.000332s) BEGIN
E, [2014-06-19T09:54:02.262007 #40260] ERROR -- : PG::InvalidTextRepresentation: ERROR: missing dimension value
LINE 1: ..." = '2014-06-06 12:37:07.485542-0400', "scopes" = '["public"...
^: UPDATE "oauth_access_tokens SET "resource_owner_id" = 2, "application_id" = 1, "token" = 'ec73426e2be81ab4772e67e139430d3896d705bcee6c141a38bd0e903e5df3eb', "refresh_token" = NULL, "expires_in" = 7200, "revoked_at" = NULL, "created_at" = '2014-06-06 12:37:07.485542-0400', "scopes" = '["public"]' WHERE ("id" = 1)
I, [2014-06-19T09:54:02.262691 #40260] INFO -- : (0.000229s) ROLLBACK
Sequel::DatabaseError: PG::InvalidTextRepresentation: ERROR: missing dimension value
LINE 1: ..." = '2014-06-06 12:37:07.485542-0400', "scopes" = '["public"...
Is what I want to do even possible with Sequel's support for postgres array types? If so, how can I allow setting token.scopes to either an Array or a Sequel::Postgres::PGArray and successfully save the model?