from typing import Optional

import pytest
from sqlmodel import Field, SQLModel, create_engine


def test_missing_sql_type():
    class CustomType:
        @classmethod
        def __get_validators__(cls):
            yield cls.validate

        @classmethod
        def validate(cls, v):
            return v
            
    with pytest.raises(ValueError):
        class Item(SQLModel, table=True):
            id: Optional[int] = Field(default=None, primary_key=True)
            item: CustomType

pytest.raises sqlmodel.Field
[((332, 357), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (345, 357), False, 'import pytest\n'), ((433, 470), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (438, 470), False, 'from sqlmodel import Field, SQLModel, create_engine\n')]