Пример #1
0
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))
Пример #2
0
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'))
Пример #3
0
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'))
Пример #4
0
def test_unique_id(case, expected):
    assert _.unique_id(*case) == expected