Skip to content

Commit

Permalink
Remove DecimalConverter (#36)
Browse files Browse the repository at this point in the history
* Remove DecimalConverter

* Update __init__.py to match

* Some fixes
  • Loading branch information
CircuitSacul committed Jan 22, 2022
1 parent 66c72b0 commit 0afdc69
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
3 changes: 1 addition & 2 deletions apgorm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from .constraints.foreign_key import ForeignKey, ForeignKeyAction
from .constraints.primary_key import PrimaryKey
from .constraints.unique import Unique
from .converter import Converter, DecimalConverter, IntEFConverter
from .converter import Converter, IntEFConverter
from .database import Database
from .field import BaseField, ConverterField, Field
from .indexes import Index, IndexType
Expand Down Expand Up @@ -121,7 +121,6 @@
"ConverterField",
"PoolAcquireContext",
"IntEFConverter",
"DecimalConverter",
"UNDEF",
"and_",
"join",
Expand Down
11 changes: 0 additions & 11 deletions apgorm/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

from __future__ import annotations

from decimal import Decimal
from enum import IntEnum, IntFlag
from typing import Generic, Type, TypeVar, Union, cast

Expand Down Expand Up @@ -68,13 +67,3 @@ def from_stored(self, value: int) -> _INTEF:

def to_stored(self, value: _INTEF) -> int:
return cast(Union[IntEnum, IntFlag], value).value


class DecimalConverter(Converter[Decimal, int]):
"""Converter that converts Decimal to int."""

def from_stored(self, value: Decimal) -> int:
return int(value)

def to_stored(self, value: int) -> Decimal:
return Decimal(value)

0 comments on commit 0afdc69

Please sign in to comment.