+
Skip to content

Add BigInteger #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 11, 2021
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ See TypeSystem for [type-specific validation keyword arguments][typesystem-field

* `orm.String(max_length)`
* `orm.Text()`
* `orm.BigInteger()`
* `orm.Boolean()`
* `orm.Integer()`
* `orm.Float()`
Expand Down
10 changes: 6 additions & 4 deletions orm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from orm.exceptions import MultipleMatches, NoMatch
from orm.fields import (
JSON,
BigInteger,
Boolean,
Date,
DateTime,
Expand All @@ -13,18 +14,19 @@
)
from orm.models import Model

__version__ = "0.1.4"
__version__ = "0.1.5"
__all__ = [
"NoMatch",
"MultipleMatches",
"BigInteger",
"Boolean",
"Integer",
"Date",
"DateTime",
"Float",
"Integer",
"String",
"Text",
"Date",
"Time",
"DateTime",
"JSON",
"ForeignKey",
"Model",
Expand Down
5 changes: 5 additions & 0 deletions orm/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def get_column_type(self):
return sqlalchemy.Integer()


class BigInteger(ModelField, typesystem.Integer):
def get_column_type(self):
return sqlalchemy.BigInteger()


class Float(ModelField, typesystem.Float):
def get_column_type(self):
return sqlalchemy.Float()
Expand Down
4 changes: 3 additions & 1 deletion tests/test_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Example(orm.Model):
__database__ = database

id = orm.Integer(primary_key=True)
huge_number = orm.BigInteger(default=9223372036854775807)
created = orm.DateTime(default=datetime.datetime.now)
created_day = orm.Date(default=datetime.date.today)
created_time = orm.Time(default=time)
Expand All @@ -46,7 +47,7 @@ def async_adapter(wrapped_func):

@functools.wraps(wrapped_func)
def run_sync(*args, **kwargs):
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
task = wrapped_func(*args, **kwargs)
return loop.run_until_complete(task)

Expand All @@ -59,6 +60,7 @@ async def test_model_crud():
await Example.objects.create()

example = await Example.objects.get()
assert example.huge_number == 9223372036854775807
assert example.created.year == datetime.datetime.now().year
assert example.created_day == datetime.date.today()
assert example.description == ""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_foreignkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def async_adapter(wrapped_func):

@functools.wraps(wrapped_func)
def run_sync(*args, **kwargs):
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
task = wrapped_func(*args, **kwargs)
return loop.run_until_complete(task)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def async_adapter(wrapped_func):

@functools.wraps(wrapped_func)
def run_sync(*args, **kwargs):
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
task = wrapped_func(*args, **kwargs)
return loop.run_until_complete(task)

Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载