Trying to learn Sequel, best practice and such.

Given a model subclass.
class DictRow < Sequel::Model

I guess the important thing here is the PK is a string and therefore
inserted, not an auto-increment integer set by the database.
Why the difference between the hash version and the block version?

On Dec 1, 2:41 pm, Jeremy Evans <[email protected]> wrote:
> On Dec 1, 11:13 am, cootcraig <[email protected]> wrote:
>
>
>
> > I guess I'm asking for trouble, but I have a table where the primary
> > key column is :key
> > Advice wanted on this.
>
> > this works
> >     DB[:dict].insert(
> >       :key => 'A',
> >       :value => '1',
> >       :creation_time => now,
> >       :modification_time => now )
>
> > Given this Model subclass
> >     class DictRow < Sequel::Model
> >     end
>
> > this works
> > dictRow.create do |r|
> >   r.key = 'Z'
> >   r.value = 99
> > end
>
> > this fails
> > dictRow.create(:key => 'Y', :value => '98', :creation_time =>
> > now, :modification_time => now)
>
> > /home/craig/.rvm/gems/ruby-1.9.2...@sequel_ex_001/gems/sequel-3.17.0/
> > lib/sequel/model/base.rb:1339:in `block in set_restricted': method
> > key= doesn't exist or access is restricted to it (Sequel::Error)
>
> As this error message states, either the key= method doesn't exist, or
> access to it is restricted.  My guess is the method does exist, but
> since it is a primary key column, you can't assign to it directly.
> You probably want to call the unrestrict_primary_key method in the
> DictRow class.
>
> Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to