Originally reported by: Michael Bayer (Bitbucket: zzzeek, GitHub: zzzeek)
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.
Originally reported by: Michael Bayer (Bitbucket: zzzeek, GitHub: zzzeek)
heres one way this could work at just the mapper level:
the
composite
function would resolve toCompositeProperty
. the columns in the row would translate toPoint(col1, col2)
and instances of thePoint
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.