fix scale and precision in decimal
This commit is contained in:
@ -37,7 +37,7 @@ def ForeignKey( # noqa CFQ002
|
||||
virtual: bool = False,
|
||||
onupdate: str = None,
|
||||
ondelete: str = None,
|
||||
) -> Type["ForeignKeyField"]:
|
||||
) -> Any:
|
||||
fk_string = to.Meta.tablename + "." + to.get_column_alias(to.Meta.pkname)
|
||||
to_field = to.Meta.model_fields[to.Meta.pkname]
|
||||
__type__ = (
|
||||
|
||||
@ -17,7 +17,7 @@ def ManyToMany(
|
||||
unique: bool = False,
|
||||
virtual: bool = False,
|
||||
**kwargs: Any
|
||||
) -> Type["ManyToManyField"]:
|
||||
) -> Any:
|
||||
to_field = to.Meta.model_fields[to.Meta.pkname]
|
||||
related_name = kwargs.pop("related_name", None)
|
||||
nullable = kwargs.pop("nullable", True)
|
||||
@ -50,7 +50,7 @@ def ManyToMany(
|
||||
class ManyToManyField(ForeignKeyField):
|
||||
through: Type["Model"]
|
||||
|
||||
if TYPE_CHECKING: # noqa: C901; pragma nocover
|
||||
if TYPE_CHECKING: # noqa: C901; #pragma nocover
|
||||
|
||||
@staticmethod
|
||||
async def add(item: "Model") -> None:
|
||||
|
||||
@ -292,14 +292,14 @@ class Decimal(ModelFieldFactory, decimal.Decimal):
|
||||
kwargs["le"] = kwargs["maximum"]
|
||||
|
||||
if kwargs.get("max_digits"):
|
||||
kwargs["scale"] = kwargs["max_digits"]
|
||||
elif kwargs.get("scale"):
|
||||
kwargs["max_digits"] = kwargs["scale"]
|
||||
kwargs["precision"] = kwargs["max_digits"]
|
||||
elif kwargs.get("precision"):
|
||||
kwargs["max_digits"] = kwargs["precision"]
|
||||
|
||||
if kwargs.get("decimal_places"):
|
||||
kwargs["precision"] = kwargs["decimal_places"]
|
||||
elif kwargs.get("precision"):
|
||||
kwargs["decimal_places"] = kwargs["precision"]
|
||||
kwargs["scale"] = kwargs["decimal_places"]
|
||||
elif kwargs.get("scale"):
|
||||
kwargs["decimal_places"] = kwargs["scale"]
|
||||
|
||||
return super().__new__(cls, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user