This commit is contained in:
Jakub Miazek
2022-11-12 18:41:39 +01:00
parent 8d44b4a5eb
commit dbe64008f8
10 changed files with 42 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
# for Alembic and unit tests
from app.models.stuff import * # noqa
from app.models.nonsense import * # noqa
from app.models.shakespeare import * # noqa
from app.models.shakespeare import * # noqa
from app.models.stuff import * # noqa

View File

@@ -13,8 +13,8 @@ class BaseReadOnly:
# Generate __tablename__ automatically
@declared_attr
def __tablename__(cls) -> str:
return cls.__name__.lower()
def __tablename__(self) -> str:
return self.__name__.lower()
@as_declarative()
@@ -24,8 +24,8 @@ class Base:
# Generate __tablename__ automatically
@declared_attr
def __tablename__(cls) -> str:
return cls.__name__.lower()
def __tablename__(self) -> str:
return self.__name__.lower()
async def save(self, db_session: AsyncSession):
"""

View File

@@ -10,9 +10,7 @@ from app.models.base import Base
class Nonsense(Base):
__tablename__ = "nonsense"
__table_args__ = (
{"schema": "happy_hog"},
)
__table_args__ = ({"schema": "happy_hog"},)
id = Column(UUID(as_uuid=True), unique=True, default=uuid.uuid4, autoincrement=True)
name = Column(String, nullable=False, primary_key=True, unique=True)
description = Column(String, nullable=False)

View File

@@ -10,9 +10,7 @@ from app.models.base import Base
class Stuff(Base):
__tablename__ = "stuff"
__table_args__ = (
{"schema": "happy_hog"},
)
__table_args__ = ({"schema": "happy_hog"},)
id = Column(UUID(as_uuid=True), unique=True, default=uuid.uuid4, autoincrement=True)
name = Column(String, nullable=False, primary_key=True, unique=True)
description = Column(String, nullable=False)