Skip to content
This repository has been archived by the owner on Mar 6, 2021. It is now read-only.

BigInteger type #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ormantic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ormantic.exceptions import MultipleMatches, NoMatch
from ormantic.fields import (
Boolean,
BigInteger,
Date,
DateTime,
Enum,
Expand All @@ -20,6 +21,7 @@
"NoMatch",
"MultipleMatches",
"Boolean",
"BigInteger",
"Date",
"Enum",
"DateTime",
Expand Down
21 changes: 21 additions & 0 deletions src/ormantic/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,27 @@ def Integer(
)
return type("Integer", (pydantic.ConstrainedInt, ColumnFactory), namespace)

def BigInteger(
*,
primary_key: bool = False,
allow_null: bool = False,
index: bool = False,
unique: bool = False,
minimum: int = None,
maximum: int = None,
multiple_of: int = None,
) -> Type[int]:
namespace = dict(
primary_key=primary_key,
allow_null=allow_null,
index=index,
unique=unique,
ge=minimum,
le=maximum,
multiple_of=multiple_of,
column_type=sqlalchemy.BigInteger(),
)
return type("BigInteger", (pydantic.ConstrainedInt, ColumnFactory), namespace)

def Float(
*,
Expand Down