(self)
| 3179 | ) |
| 3180 | |
| 3181 | def test_viewonly(self): |
| 3182 | t1t2, t2, t1 = (self.tables.t1t2, self.tables.t2, self.tables.t1) |
| 3183 | |
| 3184 | class A(ComparableEntity): |
| 3185 | pass |
| 3186 | |
| 3187 | class B(ComparableEntity): |
| 3188 | pass |
| 3189 | |
| 3190 | self.mapper_registry.map_imperatively( |
| 3191 | A, |
| 3192 | t1, |
| 3193 | properties={ |
| 3194 | "bs": relationship( |
| 3195 | B, secondary=t1t2, backref=backref("as_", viewonly=True) |
| 3196 | ) |
| 3197 | }, |
| 3198 | ) |
| 3199 | self.mapper_registry.map_imperatively(B, t2) |
| 3200 | |
| 3201 | configure_mappers() |
| 3202 | |
| 3203 | sess = fixture_session() |
| 3204 | a1 = A() |
| 3205 | b1 = B(as_=[a1]) |
| 3206 | |
| 3207 | assert not inspect(b1).attrs.as_.history.has_changes() |
| 3208 | |
| 3209 | sess.add(a1) |
| 3210 | sess.flush() |
| 3211 | eq_(sess.query(A).first(), A(bs=[])) |
| 3212 | eq_(sess.query(B).first(), None) |
| 3213 | |
| 3214 | |
| 3215 | class ViewOnlyOverlappingNames(fixtures.MappedTest): |
nothing calls this directly
no test coverage detected