| | 53 | |
| | 54 | def test_wh_key_in_m2o_col_kwargs(self): |
| | 55 | class A(Entity): |
| | 56 | name = Field(String(128), default="foo") |
| | 57 | |
| | 58 | class B(Entity): |
| | 59 | # specify a different key for the column so that |
| | 60 | # it doesn't override the property when the column |
| | 61 | # gets created. |
| | 62 | a = ManyToOne('A', colname='a', |
| | 63 | column_kwargs=dict(key='a_id')) |
| | 64 | |
| | 65 | setup_all(True) |
| | 66 | |
| | 67 | assert A.table.primary_key.columns.has_key('id') |
| | 68 | assert B.table.columns.has_key('a_id') |
| | 69 | |
| | 70 | a = A() |
| | 71 | session.flush() |
| | 72 | b = B(a=a) |
| | 73 | session.flush() |
| | 74 | session.clear() |
| | 75 | |
| | 76 | assert B.query.first().a == A.query.first() |