Hi,

I'm trying to write a DM wrapper around a legacy MySQL DB. So far I've
found it really good for this but I've hit a problem where the
relationship between two tables can only be represented by
concatenating two string fields the belongs_to table to make the key
for the has n table:


class Course
  include DataMapper::Resource
  property :code, String, :field=>'Unit_Code', :key=>true, :length=>64
  has n, :unit_offerings # foreign key needs to be
concat(UO.Unit_Code,UO.Teaching_Period)
end

class UnitOffering
  include DataMapper::Resource
  property :id, Integer, :field=>'UOO_ID', :key=>true
  property :unit_code, String, :field=>'Unit_Code'
  belongs_to :course  # foreign key needs to be
concat(UO.Unit_Code,UO.Teaching_Period)
end

So that "unit_offering.course" would produce:

select C.* from courses C inner join unit_offerings UO on C.Code =
concat(UO.Unit_Code,UO.Teaching_Period);

Does anyone know if DM can abstract away this particular form of
madness?

Thanks


-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en.

Reply via email to