Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
John Lyu committed Nov 26, 2024
1 parent 6d93a46 commit 589237b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions sqlmodel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ def get_config(name: str) -> Any:

config_table = get_config("table")
if config_table is True:
# sqlalchemy mark a class as table by check if it has __tablename__ attribute
# or if __tablename__ is in __annotations__. Only set __tablename__ if it's
# a table model
if new_cls.__name__ != "SQLModel" and not hasattr(new_cls, "__tablename__"):
new_cls.__tablename__ = new_cls.__name__.lower()
# If it was passed by kwargs, ensure it's also set in config
Expand Down Expand Up @@ -667,16 +670,6 @@ def __init__(
# Ref: https://github.com/sqlalchemy/sqlalchemy/commit/428ea01f00a9cc7f85e435018565eb6da7af1b77
# Tag: 1.4.36
DeclarativeMeta.__init__(cls, classname, bases, dict_, **kw)
# # patch sqlmodel field's default value to polymorphic_identity
# if has_polymorphic:
# mapper = inspect(cls)
# polymorphic_on = mapper.polymorphic_on
# polymorphic_property = mapper.get_property_by_column(polymorphic_on)
# field = cls.model_fields.get(polymorphic_property.key)
# def get__polymorphic_identity__(kw):
# return polymorphic_identity
# if field:
# field.default_factory = get__polymorphic_identity__
else:
ModelMetaclass.__init__(cls, classname, bases, dict_, **kw)

Expand Down

0 comments on commit 589237b

Please sign in to comment.