Skip to content

Commit 6f44f4b

Browse files
committed
added a new Table to the example app, for testing JSON columns
1 parent 5910928 commit 6f44f4b

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

tests/conf/test_apps.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def test_table_finder(self):
7070
"Concert",
7171
"Manager",
7272
"Poster",
73+
"RecordingStudio",
7374
"Shirt",
7475
"Ticket",
7576
"Venue",
@@ -95,6 +96,7 @@ def test_table_finder_coercion(self):
9596
"Concert",
9697
"Manager",
9798
"Poster",
99+
"RecordingStudio",
98100
"Shirt",
99101
"Ticket",
100102
"Venue",
@@ -129,5 +131,13 @@ def test_exclude_tags(self):
129131

130132
self.assertEqual(
131133
table_class_names,
132-
["Band", "Concert", "Manager", "Shirt", "Ticket", "Venue"],
134+
[
135+
"Band",
136+
"Concert",
137+
"Manager",
138+
"RecordingStudio",
139+
"Shirt",
140+
"Ticket",
141+
"Venue",
142+
],
133143
)

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ async def drop_tables():
1717
"migration",
1818
"musician",
1919
"my_table",
20+
"recording_studio",
2021
"shirt",
2122
]:
2223
await ENGINE._run_in_new_connection(f"DROP TABLE IF EXISTS {table}")

tests/example_app/tables.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
from enum import Enum
22

33
from piccolo.table import Table
4-
from piccolo.columns import Varchar, ForeignKey, Integer, Numeric, Text
4+
from piccolo.columns import (
5+
ForeignKey,
6+
Integer,
7+
JSON,
8+
JSONB,
9+
Numeric,
10+
Text,
11+
Varchar,
12+
)
513
from piccolo.columns.readable import Readable
614

715
###############################################################################
@@ -60,3 +68,12 @@ class Size(str, Enum):
6068
large = "l"
6169

6270
size = Varchar(length=1, choices=Size, default=Size.large)
71+
72+
73+
class RecordingStudio(Table):
74+
"""
75+
Used for testing JSON and JSONB columns.
76+
"""
77+
78+
facilities = JSON()
79+
facilities_b = JSONB()

0 commit comments

Comments
 (0)