Hi there

I've run into a problem where loading models through a many_to_many
association clobbers the dataset defined in the model class.

For example:

class Company < Sequel::Model
  many_to_many :employees, :join_table => :employments, :left_key
=> :company_id, :right_key => :person_id
end

class Person < Sequel::Model
  set_dataset select(:full_name => :name)
end

In irb:

> Person.first    # {:name => "John Appleseed"}
> Company.first.employees.first    # {:full_name => "John Appleseed"} but 
> should be {:name => "John Appleseed"}

If I change the many_to_many to alias the columns I get the expected
result, but this is undesirable as I have duplicated the aliases
across two classes:

class Company < Sequel::Model
  many_to_many :employees, :join_table => :employments, :left_key
=> :company_id, :right_key => :person_id, :select => [:full_name
=> :name]
end

How do I get the association to use the default dataset defined in the
Person class when loading the records? Am I going about this the wrong
way?

Thanks

-- 
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