composite types

Issue #211 resolved
Mike Bayer repo owner created an issue

heres one way this could work at just the mapper level:

   class Point(object):
       def __init__(self, x, y):
           self.x = x
           self.y = y
       def __colset__(self):
           return [self.y](self.x,)

   mapper(class, table, properties={
         'vertex':composite(table.c.xpos, table.c.ypos, Point)
    }
   )

the composite function would resolve to CompositeProperty. the columns in the row would translate to Point(col1, col2) and instances of the Point class would be translated back via __colset__ (or something like that).

should composite types be available at the table level ? probably not since Tables are supposed to act like database tables.

Comments (3)

  1. Mike Bayer reporter
    • changed milestone to 0.4.0
    • changed component to orm

    i think this is an important feature, analgous to hibernate's "<component>" mapping.

  2. Log in to comment