On Aug 21, 2008, at 9:03 AM, [EMAIL PROTECTED] wrote:
> > hi > i plan to implement "embedded structures" in dbcook (as opposed to > referenced structures living in separate tables), and composite props > seems to fit nicely. > > the idea is to achieve something like: > > class Point( embeddableBase): > x = Int() > y = Int() > > class Vertex( base): > p1 = Point() > p2 = Point() > > which should create a table/mapping > with columns ( p1_x, p1_y, p2_x, p2_y ) and a mapper with the p1, p2 > as composite_props. > > the plain columns are still accessible via the mapper, right? e.g. > query(Vertex).filter( Vertex.p1_x >4 ) > can composite's props be used in query expressions? e.g. > query(Vertex).filter( Vertex.p1.x > 4 ) Not by default, the composite attribute p1 and p2 would prevent p1_x, p1_y, etc. from being mapped. you could try explicitly mapping them, i havent experimented much with that. it becomes a gray area since which attribute would it favor for the ultimate value to be persisted? plain descriptors look like a better solution here (composites are probably an unnecessary feature in the first place). > > > can composite's props be assigned separately ? e.g. would this work? > v = Vertex( ...) > v.p1.x = 3 > v.p2 = Point( 1,2) > v.p1_y = 5 yeah that wont work at all. With a descriptor based approach (and a Point object that knows how to proxy to the parent object), it could. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---