Hi,
I am just getting started with sequel. I looked but didn't find
anything similar in the archives or docs.
I am trying to make sequel work with some legacy mysql tables. I am
having the following tables:
Child (primary key- composite of :id and :acad_year) and other fields
Parent(primary key - composite of :id and :acad_year) and other fields
Attendance(primary key - composite of child_id, class)
(Basically child has many to one relationship with parent, child has
one to many relationship with attendance)
I have the following model definitions:
class Parent < Sequel::Model(:parents)
set_primary_key :id, : acad_year
end
class Child < Sequel::Model(:child)
set_primary_key :id, :acad_year
end
class Attendance < Sequel::Model(:attendance)
many_to_one :child, :key=>'child_id'
end
So I expect to be able to load the Child instance directly from
Attendace like this:
>> af=Attendance.first
=> #<Attendance @values={:class=>"2", :child_id=>1, :week=>#<Date:
4910175/2,0,2299161>, :present=>"no"}>
>> af.child_id
=> 1
>> af.child
=> nil
I think this is the problem:
>> af.child_dataset
=> #<Sequel::MySQL::Dataset: "SELECT * FROM `child` WHERE
((`child`.`id` = 1) AND (`child`.`acad_year` IS NULL))">
How do I specify the acad_year field (which is known to me) to get the
associated record correctly ?
Thanks!
Journeyer
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---