Hi,
I have the following situation:
class Film < Sequel::Model
KEYS = {
:tijd => :time,
:zender => :text,
:title => :text,
:director => :text,
:top250 => :integer,
:rating => :float,
:votes => :integer,
:ebert => :float,
:users => :float,
:eberturl => :text,
:nreviews => :integer,
:url => :text
}
set_schema do
KEYS.each_pair do |elem, type|
column elem, type
end
index([:tijd, :zender], { :unique => true })
end
set_primary_key [:tijd, :zender]
given a hash, newval with symbols as keys,
film = Film.create(newval)
and
film = Film.create(newval){}
both don't work:
/usr/lib64/ruby/gems/1.8/gems/sequel-2.6.0/lib/sequel_model/record.rb:
500:in `set_restricted': method tijd= doesn't exist or access is
restricted to it (Sequel::Error)
(It probably has to do with the fact that tijd is part of the primary
key).
film = Film.create do |f|
f = newval
end
doesn't work either, but doesn't raise an exception either. Instead
is generates the following SQL:
INSERT INTO `films` DEFAULT VALUES
SELECT * FROM `films` WHERE ((`tijd` IS NULL) AND (`zender` IS NULL))
LIMIT 1
Finally:
film = Film.create do |f|
newval.each_pair do |k, v|
f[k] = v
end
end
works as expected.
Have I misread the documentation, and is film = Film.create(newval)
expected not to work, or is this something to follow up ?
Han Holl
PS Database is sqlite3, Linux Fedora 8.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---