Skip to content

Commit 859a4af

Browse files
committed
Testing git test runner with commented out code
1 parent 3d4be3a commit 859a4af

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

sqlmodel/_compat.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Dict,
1111
ForwardRef,
1212
Generator,
13+
Literal,
1314
Mapping,
1415
Optional,
1516
Set,
@@ -22,6 +23,7 @@
2223
from pydantic import BaseModel
2324
from pydantic.fields import FieldInfo
2425
from typing_extensions import Annotated, get_args, get_origin
26+
from .sql.sqltypes import AutoString
2527

2628
# Reassign variable to make it reexported for mypy
2729
PYDANTIC_VERSION = P_VERSION
@@ -458,10 +460,12 @@ def is_field_noneable(field: "FieldInfo") -> bool:
458460
)
459461
return field.allow_none # type: ignore[no-any-return, attr-defined]
460462

461-
def get_sa_type_from_field(field: Any) -> Any:
462-
if isinstance(field.type_, type) and field.shape == SHAPE_SINGLETON:
463-
return field.type_
464-
raise ValueError(f"The field {field.name} has no matching SQLAlchemy type")
463+
# def get_sa_type_from_field(field: Any) -> Any:
464+
# if field is Literal:
465+
# return AutoString
466+
# elif isinstance(field.type_, type) and field.shape == SHAPE_SINGLETON:
467+
# return field.type_
468+
# raise ValueError(f"The field {field.name} has no matching SQLAlchemy type")
465469

466470
def get_field_metadata(field: Any) -> Any:
467471
metadata = FakeMetadata()

tests/test_main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ class Hero(SQLModel, table=True):
135135
name: str = Field(unique=True)
136136
weakness: Literal["Kryptonite", "Dehydration", "Munchies"]
137137

138-
superman = Hero(name="Superman", weakness="Kryptonite")
138+
superguy = Hero(name="Superguy", weakness="Kryptonite")
139139

140140
engine = create_engine("sqlite://", echo=True)
141141

142142
SQLModel.metadata.create_all(engine)
143143

144144
with Session(engine) as session:
145-
session.add(superman)
145+
session.add(superguy)
146146
session.commit()
147-
session.refresh(superman)
148-
assert superman.weakness == "Kryptonite"
149-
assert isinstance(superman.weakness, str)
147+
session.refresh(superguy)
148+
assert superguy.weakness == "Kryptonite"
149+
assert isinstance(superguy.weakness, str)

0 commit comments

Comments
 (0)