|
2 | 2 | import enum |
3 | 3 | import random |
4 | 4 | import string |
| 5 | +import uuid |
5 | 6 | from datetime import datetime |
6 | 7 |
|
7 | 8 | import pytest |
8 | 9 |
|
9 | 10 | from gino import Gino |
10 | 11 | from gino.dialects.asyncpg import JSONB |
| 12 | +from sqlalchemy.dialects.postgresql import UUID |
| 13 | + |
11 | 14 |
|
12 | 15 | DB_ARGS = dict( |
13 | 16 | host=os.getenv("DB_HOST", "localhost"), |
@@ -134,19 +137,23 @@ def add_team(self, team): |
134 | 137 | class UserSetting(db.Model): |
135 | 138 | __tablename__ = "gino_user_settings" |
136 | 139 |
|
137 | | - # No constraints defined on columns |
| 140 | + # No constraints defined on these columns |
138 | 141 | id = db.Column(db.BigInteger()) |
139 | 142 | user_id = db.Column(db.BigInteger()) |
140 | 143 | setting = db.Column(db.Text()) |
141 | 144 | value = db.Column(db.Text()) |
142 | 145 | col1 = db.Column(db.Integer, default=1) |
143 | 146 | col2 = db.Column(db.Integer, default=2) |
144 | 147 |
|
| 148 | + # Some constraints defined on these columns |
| 149 | + col3 = db.Column(UUID, default=uuid.uuid4, unique=True) |
| 150 | + col4 = db.Column(db.Integer, default=4, nullable=False) |
| 151 | + |
145 | 152 | # Define indexes and constraints inline |
146 | 153 | id_pkey = db.PrimaryKeyConstraint("id") |
147 | 154 | user_id_fk = db.ForeignKeyConstraint(["user_id"], ["gino_users.id"]) |
148 | 155 | user_id_setting_unique = db.UniqueConstraint("user_id", "setting") |
149 | | - col1_check = db.CheckConstraint("col1 >= 1 AND col1 <= 5") |
| 156 | + col1_check = db.CheckConstraint("col1 >= 1 AND col1 <= 5", "check_col1") |
150 | 157 | col2_idx = db.Index("col2_idx", "col2") |
151 | 158 |
|
152 | 159 |
|
|
0 commit comments