Passed
Push — main ( 4cd557...ac26d8 )
by torrua
01:36
created

loglan_db.model_db.base_key   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 44
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 0
1
# -*- coding: utf-8 -*-
2
# pylint: disable=C0303
3 1
"""
4
This module contains a basic Key Model
5
"""
6 1
from loglan_db.model_db import t_name_keys
7 1
from loglan_db.model_db.base_word import db
8 1
from loglan_db.model_init import InitBase, DBBase
9
10
11 1
class BaseKey(db.Model, InitBase, DBBase):
12
    """Base Key's DB Model
13
14
    Describes a table structure for storing information
15
    about key words of the word's definitions.
16
    Some key words could belong to many definitions
17
    and some definitions could have many key words.
18
    That's why the relationship between Key
19
    and Definition should be many-to-many. See `t_connect_keys`.
20
21
    There is additional `word_language` UniqueConstraint here.
22
23
    <details><summary>Show Examples</summary><p>
24
    ```python
25
    {'language': 'en', 'word': 'aura', 'id': 1234}
26
27
    {'language': 'en', 'word': 'emotionality', 'id': 4321}
28
    ```
29
    </p></details>
30
    """
31 1
    __tablename__ = t_name_keys
32 1
    __table_args__ = (
33
        db.UniqueConstraint('word', 'language', name='_word_language_uc'), )
34
35 1
    id = db.Column(db.Integer, primary_key=True)
36
    """*Key's internal ID number*  
37
        **int** : primary_key=True"""
38 1
    word = db.Column(db.String(64), nullable=False, unique=False)
39
    """*Key's vernacular word*  
40
        **str** : max_length=64, nullable=False, unique=False  
41
    It is non-unique, as words can be the same in spelling in different languages"""
42 1
    language = db.Column(db.String(16), nullable=False, unique=False)
43 1
    """*Key's language*  
44
        **str** : max_length=16, nullable=False, unique=False"""
45