summaryrefslogtreecommitdiff
path: root/test/ext/mypy/plugin_files/mixin_w_tablename.py
blob: cfbe83d35db230dce2f353316d5e05036cb55783 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# test #6937
from sqlalchemy import Column
from sqlalchemy import Integer
from sqlalchemy.orm import declarative_base
from sqlalchemy.orm import declared_attr
from sqlalchemy.orm import Mapped


Base = declarative_base()


class UpdatedCls:
    @declared_attr
    def __tablename__(cls) -> Mapped[str]:
        return cls.__name__.lower()

    updated_at = Column(Integer)


class Bar(UpdatedCls, Base):
    id = Column(Integer(), primary_key=True)
    num = Column(Integer)


Bar.updated_at.in_([1, 2, 3])

b1 = Bar(num=5, updated_at=6)