-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
constants.py
141 lines (131 loc) · 4.26 KB
/
constants.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
from __future__ import annotations
from typing import List, cast
from pathlib import Path
from typing_extensions import get_args
from lib import pyright
from .utils import DatabaseConfig, DatabaseFeature
from ._types import DatabaseMapping, SupportedDatabase
def _fromdir(path: str) -> list[str]:
"""Get the contents of a subdirectory within the `` directory"""
# TODO: recurse subdirs
return [str(f.relative_to(TESTS_DIR)) for f in (TESTS_DIR / path).iterdir()]
# databases
CONFIG_MAPPING: DatabaseMapping[DatabaseConfig] = {
'postgresql': DatabaseConfig(
id='postgresql',
name='PostgreSQL',
env_var='POSTGRESQL_URL',
bools_are_ints=False,
unsupported_features=set(),
default_date_func='CURRENT_DATE',
autoincrement_id='Int @id @default(autoincrement())',
),
'cockroachdb': DatabaseConfig(
id='cockroachdb',
name='CockroachDB',
env_var='COCKROACHDB_URL',
bools_are_ints=False,
default_date_func='CURRENT_DATE',
autoincrement_id='BigInt @id @default(sequence())',
unsupported_features={
'json_arrays',
'array_push',
'transactions',
'full_text_search',
},
),
'sqlite': DatabaseConfig(
id='sqlite',
name='SQLite',
env_var='SQLITE_URL',
bools_are_ints=False,
default_date_func='',
autoincrement_id='Int @id @default(autoincrement())',
unsupported_features={
'enum',
'json',
'date',
'arrays',
'create_many_skip_duplicates',
'case_sensitivity',
'full_text_search',
},
),
'mysql': DatabaseConfig(
id='mysql',
name='MySQL',
env_var='MYSQL_URL',
bools_are_ints=True,
default_date_func='(CURRENT_DATE)',
autoincrement_id='Int @id @default(autoincrement())',
unsupported_features={
'arrays',
'case_sensitivity',
},
),
'mariadb': DatabaseConfig(
id='mysql',
name='MariaDB',
env_var='MARIADB_URL',
bools_are_ints=True,
default_date_func='CURRENT_DATE',
autoincrement_id='Int @id @default(autoincrement())',
unsupported_features={
'arrays',
'case_sensitivity',
'full_text_search',
},
),
}
SUPPORTED_DATABASES = cast(List[SupportedDatabase], list(get_args(SupportedDatabase)))
# paths
ROOT_DIR = Path(__file__).parent.parent
DATABASES_DIR = Path(__file__).parent
# database features
TESTS_DIR = DATABASES_DIR / 'tests'
SYNC_TESTS_DIR = DATABASES_DIR / 'sync_tests'
FEATURES_MAPPING: dict[DatabaseFeature, list[str]] = {
'enum': ['test_enum.py', 'test_arrays/test_enum.py'],
'json': [
'types/test_json.py',
'test_arrays/test_json.py',
'types/raw_queries/test_json.py',
],
'arrays': [*_fromdir('arrays'), *_fromdir('types/raw_queries/arrays')],
'array_push': _fromdir('arrays/push'),
'json_arrays': ['arrays/test_json.py', 'arrays/push/test_json.py'],
'transactions': ['test_transactions.py'],
# not yet implemented
'date': [],
'create_many_skip_duplicates': ['test_create_many_skip_duplicates.py'],
'raw_queries': ['test_raw_queries.py', *_fromdir('types/raw_queries')],
'case_sensitivity': ['test_case_sensitivity.py'],
'full_text_search': ['test_full_text_search.py'],
}
# config files
PYRIGHT_CONFIG: pyright.Config = {
'include': [],
'exclude': ['../src/prisma/_vendor/**.py', '**/prisma/_vendor/**.py'],
# required so that Pyright can resolve the `lib` module
'extraPaths': ['../'],
'typeCheckingMode': 'strict',
'reportPrivateUsage': False,
# copied from `pyproject.toml`
'reportUnusedImport': True,
'reportPrivateUsage': False,
'reportImportCycles': False,
'reportUnknownMemberType': False,
'reportUnknownVariableType': False,
'reportUnknownArgumentType': False,
# very strict errors
'reportImplicitOverride': True,
'reportUnusedCallResult': False,
'reportImplicitStringConcatenation': False,
'reportCallInDefaultInitializer': True,
}
PYTEST_CONFIG = {
'[tool.pytest.ini_options]': {
'asyncio_mode': 'strict',
'ignore': [],
},
}