forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_varchar.py
More file actions
35 lines (23 loc) · 791 Bytes
/
test_varchar.py
File metadata and controls
35 lines (23 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from unittest import TestCase
from piccolo.table import Table
from piccolo.columns.column_types import Varchar
from ..base import postgres_only
class MyTable(Table):
name = Varchar(length=10)
@postgres_only
class TestVarchar(TestCase):
"""
SQLite doesn't enforce any constraints on max character length.
https://www.sqlite.org/faq.html#q9
Might consider enforncing this at the ORM level instead in the future.
"""
def setUp(self):
MyTable.create_table().run_sync()
def tearDown(self):
MyTable.alter().drop_table().run_sync()
def test_length(self):
row = MyTable(name="bob")
row.save().run_sync()
with self.assertRaises(Exception):
row.name = "bob123456789"
row.save().run_sync()