Hi Jeremy,

thanks for the quick reply; unfortunately, that does not seem to make a
difference. I've put together a Gist to show what I am doing (and to make
sure my other code doesn't interfere with anything):
https://gist.github.com/lutter/6431747

I am running this under JRuby 1.7.4 with 'jruby pg_array_test.rb'

If I comment out the two validation plugins, it seems that Sequel somehow
gets confused about the type of hw_info. It generates

INSERT INTO "nodes" ("hw_info") VALUES (ARRAY['serial=1']::text[]) RETURNING *

for the create, which is correct, but then

UPDATE "nodes" SET "hw_info" = ('serial=1') WHERE ("id" = 1)

Which is missing the coercion to array (probably connected to the fact
that after the create,
n.hw_info is an Array, not a PGArray)

Any help is much appreciated.

David



On Tue, Sep 3, 2013 at 5:53 PM, Jeremy Evans <[email protected]> wrote:

> On Tuesday, September 3, 2013 5:41:26 PM UTC-7, David Lutterkort wrote:
>
>> Hi all,
>>
>> I hope this is the right place to ask this kind of question; I am having
>> trouble using a PGArray in one of my models.
>>
>> The table backing the model looks like this:
>>
>> create_table :nodes do
>>   primary_key :id
>>   column :hw_info, 'Text[]', :null => false
>>   ... other stuff ...
>> end
>>
>> My model class (which is just 'class Node < Sequel::Model; end') behaves
>> strange:
>>
>> # This works fine
>> n = Node.create(:hw_info => ["serial=1"])
>>
>> # Here's the trouble; blows up with
>> #   'Sequel::ValidationFailed: hw_info is not a valid
>> sequel::postgres::pgarray'
>> n.save
>>
>> What am I doing wrong ? I am loading the relevant extensions on my DB:
>>
>> Sequel.extension :core_extensions, :inflector
>> Sequel.extension :pg_array, :pg_array_ops
>>
>
> This should be:
>
> Sequel.extension :core_extensions, :inflector
> DB.extension :pg_array
> Sequel.extension :pg_array_ops
>
> You have to load the extension into your Database instance so that it has
> the necessary type conversion methods.
>
> Thanks,
> Jeremy
>
> --
> You received this message because you are subscribed to the Google Groups
> "sequel-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sequel-talk.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to