Add unique constraint, None option

This commit is contained in:
Ege Emir Özkan
2020-08-22 01:00:30 +03:00
parent 6f58590475
commit 768453ab39
10 changed files with 179 additions and 12 deletions

View File

@@ -0,0 +1,26 @@
"""
datalite.constraints module introduces constraint
types that can be used to hint field variables,
that can be used to signal datalite decorator
constraints in the database.
"""
from typing import TypeVar, Union, Tuple
T = TypeVar('T')
class ConstraintFailedError(Exception):
"""
This exception is raised when a Constraint fails.
"""
pass
"""
Dataclass fields hinted with this type signals
datalite that the bound column of this
field in the table is NOT NULL and UNIQUE.
"""
Unique = Union[Tuple[T], T]