Skip to content

Commit 589237b

Browse files
author
John Lyu
committed
improve docs
1 parent 6d93a46 commit 589237b

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

sqlmodel/main.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,9 @@ def get_config(name: str) -> Any:
568568

569569
config_table = get_config("table")
570570
if config_table is True:
571+
# sqlalchemy mark a class as table by check if it has __tablename__ attribute
572+
# or if __tablename__ is in __annotations__. Only set __tablename__ if it's
573+
# a table model
571574
if new_cls.__name__ != "SQLModel" and not hasattr(new_cls, "__tablename__"):
572575
new_cls.__tablename__ = new_cls.__name__.lower()
573576
# If it was passed by kwargs, ensure it's also set in config
@@ -667,16 +670,6 @@ def __init__(
667670
# Ref: https://github.com/sqlalchemy/sqlalchemy/commit/428ea01f00a9cc7f85e435018565eb6da7af1b77
668671
# Tag: 1.4.36
669672
DeclarativeMeta.__init__(cls, classname, bases, dict_, **kw)
670-
# # patch sqlmodel field's default value to polymorphic_identity
671-
# if has_polymorphic:
672-
# mapper = inspect(cls)
673-
# polymorphic_on = mapper.polymorphic_on
674-
# polymorphic_property = mapper.get_property_by_column(polymorphic_on)
675-
# field = cls.model_fields.get(polymorphic_property.key)
676-
# def get__polymorphic_identity__(kw):
677-
# return polymorphic_identity
678-
# if field:
679-
# field.default_factory = get__polymorphic_identity__
680673
else:
681674
ModelMetaclass.__init__(cls, classname, bases, dict_, **kw)
682675

0 commit comments

Comments
 (0)