class BModel(Model): __tablename__ = 'test_b' id1 = sa.Column(sa.types.Integer(), primary_key=True, default=lambda val: int(pyd.unique_id())) id2 = sa.Column(sa.types.Integer(), primary_key=True, default=lambda val: int(pyd.unique_id())) name = sa.Column(sa.types.String(50))
class DModel(Model): __tablename__ = 'test_d' id = sa.Column(sa.types.Integer(), primary_key=True, default=lambda val: int(pyd.unique_id())) name = sa.Column(sa.types.String(50)) a_id = sa.Column(sa.types.Integer(), sa.ForeignKey('test_a.id'))
class AModel(Model): __tablename__ = 'test_a' id = sa.Column(sa.types.Integer(), primary_key=True, default=lambda val: int(pyd.unique_id())) name = sa.Column(sa.types.String(50)) text = sa.Column(sa.types.String(50)) c_id = sa.Column(sa.types.Integer(), sa.ForeignKey('test_c.id')) c = sa.orm.relation('CModel') ds = sa.orm.relation('DModel') d_map = sa.orm.relation('DModel', collection_class=attribute_mapped_collection('id'))
def test_unique_id(case, expected): assert _.unique_id(*case) == expected