| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -415,6 +415,7 @@ def get_sqlachemy_type(field: ModelField) -> Any: | |||
| 415 | 415 | return AutoString | |
| 416 | 416 | if issubclass(field.type_, uuid.UUID): | |
| 417 | 417 | return GUID | |
| 418 | + raise ValueError(f"The field {field.name} has no matching SQLAlchemy type") | ||
| 418 | 419 | ||
| 419 | 420 | ||
| 420 | 421 | def get_column_from_field(field: ModelField) -> Column: # type: ignore | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + from typing import Optional | ||
| 2 | + | ||
| 3 | + import pytest | ||
| 4 | + from sqlmodel import Field, SQLModel | ||
| 5 | + | ||
| 6 | + | ||
| 7 | + def test_missing_sql_type(): | ||
| 8 | + class CustomType: | ||
| 9 | + @classmethod | ||
| 10 | + def __get_validators__(cls): | ||
| 11 | + yield cls.validate | ||
| 12 | + | ||
| 13 | + @classmethod | ||
| 14 | + def validate(cls, v): | ||
| 15 | + return v | ||
| 16 | + | ||
| 17 | + with pytest.raises(ValueError): | ||
| 18 | + | ||
| 19 | + class Item(SQLModel, table=True): | ||
| 20 | + id: Optional[int] = Field(default=None, primary_key=True) | ||
| 21 | + item: CustomType | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments