mirror of
https://github.com/fastapi/sqlmodel.git
synced 2025-11-01 19:31:00 +08:00
✨ Add support for Decimal fields from Pydantic and SQLAlchemy (#103)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
@ -399,7 +399,10 @@ def get_sqlachemy_type(field: ModelField) -> Any:
|
||||
if issubclass(field.type_, bytes):
|
||||
return LargeBinary
|
||||
if issubclass(field.type_, Decimal):
|
||||
return Numeric
|
||||
return Numeric(
|
||||
precision=getattr(field.type_, "max_digits", None),
|
||||
scale=getattr(field.type_, "decimal_places", None),
|
||||
)
|
||||
if issubclass(field.type_, ipaddress.IPv4Address):
|
||||
return AutoString
|
||||
if issubclass(field.type_, ipaddress.IPv4Network):
|
||||
|
||||
Reference in New Issue
Block a user