Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sqlmodel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def __init__(
# triggers an error
base_is_table = False
for base in bases:
config = getattr(base, "__config__")
config = getattr(base, "__config__", None)
if config and getattr(config, "table", False):
base_is_table = True
break
Expand Down
23 changes: 23 additions & 0 deletions tests/test_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from typing import Optional

import pytest
from sqlmodel import Field, SQLModel


class FooMixin:
pass


@pytest.mark.usefixtures("clear_sqlmodel")
def test_mixin():
"""Test SQLModel in combination with a mixin.

https://github.com/tiangolo/sqlmodel/issues/254

"""

class Hero(FooMixin, SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str
secret_name: str
age: Optional[int] = None