ColumnProperty with ManyToMany

32 views
Skip to first unread message

r.eggers

unread,
Oct 12, 2015, 5:17:50 AM10/12/15
to Project Camelot
Hello All,

I'm trying to use a ColumnProperty to retrieve a field from a ManyToMany relationship. The following code, which is added to the Movie class, reproduces the problem in the Videostore tutorial application.

    @ColumnProperty

     def no_tags( self ):

         from_obj = orm.join(Movie,Tag,Movie.tags)

         return sql.select(sql.func.count([Tag.id)],from_obj=from_obj,

             whereclause=sql.and_(Movie.id == self.id ))

I expect a different number for each row/Movie. However, I do get the same value for each row.

Does ColumnProperty work with ManyToMany relationships and joins? Am I doing something wrong here? Do I possibly need to explicitly use the cross-link table?



Reply all
Reply to author
Forward
0 new messages