Skip to content

Commit d50b8f4

Browse files
committed
add tests for SmallInt and BigInt
1 parent 60e5ca7 commit d50b8f4

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

piccolo/columns/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _validate_default(
359359
):
360360
self._validated = True
361361
return True
362-
elif inspect.isfunction(default):
362+
elif callable(default):
363363
# We need to prevent recursion, otherwise a function which returns
364364
# a function would be an infinite loop.
365365
if allow_recursion and self._validate_default(

tests/apps/migrations/auto/integration/test_migrations.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99

1010
from piccolo.columns.defaults.uuid import UUID4
1111
from piccolo.conf.apps import AppConfig
12-
from piccolo.columns.column_types import Integer, Text, UUID, Varchar
12+
from piccolo.columns.column_types import (
13+
BigInt,
14+
Integer,
15+
SmallInt,
16+
Text,
17+
UUID,
18+
Varchar,
19+
)
1320
from piccolo.apps.migrations.commands.new import (
1421
_create_new_migration,
1522
_create_migrations_folder,
@@ -137,6 +144,38 @@ def test_integer_column(self):
137144
]
138145
)
139146

147+
def test_smallint_column(self):
148+
self._test_migrations(
149+
table_classes=[
150+
self.table(column)
151+
for column in [
152+
SmallInt(),
153+
SmallInt(default=1),
154+
SmallInt(default=integer_default),
155+
SmallInt(null=True),
156+
SmallInt(null=False),
157+
SmallInt(index=True),
158+
SmallInt(index=False),
159+
]
160+
]
161+
)
162+
163+
def test_bigint_column(self):
164+
self._test_migrations(
165+
table_classes=[
166+
self.table(column)
167+
for column in [
168+
BigInt(),
169+
BigInt(default=1),
170+
BigInt(default=integer_default),
171+
BigInt(null=True),
172+
BigInt(null=False),
173+
BigInt(index=True),
174+
BigInt(index=False),
175+
]
176+
]
177+
)
178+
140179
def test_uuid_column(self):
141180
self._test_migrations(
142181
table_classes=[

0 commit comments

Comments
 (0)