@ai-devtools/dbspec-windows-x64 0.7.18 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/dbspec/_internal/base_library.zip +0 -0
- package/bin/dbspec/_internal/dbspec.egg-info/PKG-INFO +2 -2
- package/bin/dbspec/_internal/dbspec.egg-info/SOURCES.txt +4 -0
- package/bin/dbspec/_internal/dbspec.egg-info/requires.txt +1 -1
- package/bin/dbspec/_internal/pyproject.toml +2 -2
- package/bin/dbspec/_internal/src/resources/sqlalchemy_templates/model.py.j2 +29 -1
- package/bin/dbspec/dbspec.exe +0 -0
- package/package.json +1 -1
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dbspec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: DBSpec: CLI/TUI for database design (Excel as DSL)
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -8,7 +8,7 @@ Requires-Dist: textual
|
|
|
8
8
|
Requires-Dist: rich
|
|
9
9
|
Requires-Dist: openpyxl
|
|
10
10
|
Requires-Dist: pydantic>=2.0.0
|
|
11
|
-
Requires-Dist: sqlalchemy
|
|
11
|
+
Requires-Dist: sqlalchemy>=2.0.16
|
|
12
12
|
Requires-Dist: alembic
|
|
13
13
|
Requires-Dist: psycopg[binary]
|
|
14
14
|
Requires-Dist: jinja2
|
|
@@ -24,11 +24,13 @@ src/cli_commands/validate.py
|
|
|
24
24
|
src/cli_commands/xlsx.py
|
|
25
25
|
src/db_import/__init__.py
|
|
26
26
|
src/db_import/cli_renderer.py
|
|
27
|
+
src/db_import/constraints.py
|
|
27
28
|
src/db_import/importer.py
|
|
28
29
|
src/db_import/result.py
|
|
29
30
|
src/db_import/tui_adapter.py
|
|
30
31
|
src/generators/__init__.py
|
|
31
32
|
src/generators/sqlalchemy/__init__.py
|
|
33
|
+
src/generators/sqlalchemy/constraints.py
|
|
32
34
|
src/generators/sqlalchemy/context.py
|
|
33
35
|
src/generators/sqlalchemy/enums.py
|
|
34
36
|
src/generators/sqlalchemy/generate.py
|
|
@@ -39,12 +41,14 @@ src/generators/sqlalchemy/types.py
|
|
|
39
41
|
src/logic/__init__.py
|
|
40
42
|
src/logic/check_rules.py
|
|
41
43
|
src/logic/db_validation.py
|
|
44
|
+
src/logic/db_validation_constraints.py
|
|
42
45
|
src/logic/diagnostics.py
|
|
43
46
|
src/logic/parser.py
|
|
44
47
|
src/logic/validator.py
|
|
45
48
|
src/logic/validation_rules/__init__.py
|
|
46
49
|
src/logic/validation_rules/base.py
|
|
47
50
|
src/logic/validation_rules/check_rules.py
|
|
51
|
+
src/logic/validation_rules/constraints.py
|
|
48
52
|
src/logic/validation_rules/domains.py
|
|
49
53
|
src/logic/validation_rules/enums.py
|
|
50
54
|
src/logic/validation_rules/foreign_keys.py
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dbspec"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "1.0.0"
|
|
8
8
|
description = "DBSpec: CLI/TUI for database design (Excel as DSL)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -13,7 +13,7 @@ dependencies = [
|
|
|
13
13
|
"rich",
|
|
14
14
|
"openpyxl",
|
|
15
15
|
"pydantic>=2.0.0",
|
|
16
|
-
"sqlalchemy",
|
|
16
|
+
"sqlalchemy>=2.0.16",
|
|
17
17
|
"alembic",
|
|
18
18
|
"psycopg[binary]",
|
|
19
19
|
"jinja2",
|
|
@@ -70,6 +70,9 @@ from ..{{ common_dir_name }}.base import metadata
|
|
|
70
70
|
{% if col.is_pk and not table.pk_constraint -%}
|
|
71
71
|
{% set _ = col_args.append('primary_key=True') -%}
|
|
72
72
|
{% endif -%}
|
|
73
|
+
{% if col.disable_autoincrement -%}
|
|
74
|
+
{% set _ = col_args.append('autoincrement=False') -%}
|
|
75
|
+
{% endif -%}
|
|
73
76
|
{% if col.is_unique -%}
|
|
74
77
|
{% set _ = col_args.append('unique=True') -%}
|
|
75
78
|
{% endif -%}
|
|
@@ -102,6 +105,17 @@ from ..{{ common_dir_name }}.base import metadata
|
|
|
102
105
|
{% for check in table.check_constraints %}
|
|
103
106
|
CheckConstraint("{{ check.expression | replace('"', '\\"') }}", name="{{ check.name }}"),
|
|
104
107
|
{% endfor %}
|
|
108
|
+
{% for constraint in table.unique_constraints %}
|
|
109
|
+
UniqueConstraint(
|
|
110
|
+
{% for c in constraint.columns %}
|
|
111
|
+
"{{ c }}",
|
|
112
|
+
{% endfor %}
|
|
113
|
+
name="{{ constraint.name }}",
|
|
114
|
+
{% if constraint.nulls_not_distinct %}
|
|
115
|
+
postgresql_nulls_not_distinct=True,
|
|
116
|
+
{% endif %}
|
|
117
|
+
),
|
|
118
|
+
{% endfor %}
|
|
105
119
|
{% for idx in table.indexes %}
|
|
106
120
|
{% if idx.unique and not idx.where %}
|
|
107
121
|
UniqueConstraint(
|
|
@@ -202,7 +216,7 @@ class {{ table.class_name }}({{ base_class }}):
|
|
|
202
216
|
|
|
203
217
|
__tablename__ = "{{ table.table }}" # type: ignore[assignment]
|
|
204
218
|
|
|
205
|
-
{% set has_table_level_args = (table.indexes and (table.indexes | length > 0)) or (table.pk_constraint and table.pk_constraint.columns) or (table.check_constraints and (table.check_constraints | length > 0)) %}
|
|
219
|
+
{% set has_table_level_args = (table.indexes and (table.indexes | length > 0)) or (table.unique_constraints and (table.unique_constraints | length > 0)) or (table.pk_constraint and table.pk_constraint.columns) or (table.check_constraints and (table.check_constraints | length > 0)) %}
|
|
206
220
|
{% if has_table_level_args %}
|
|
207
221
|
__table_args__ = (
|
|
208
222
|
{% if table.pk_constraint and table.pk_constraint.columns %}
|
|
@@ -216,6 +230,17 @@ class {{ table.class_name }}({{ base_class }}):
|
|
|
216
230
|
{% for check in table.check_constraints %}
|
|
217
231
|
CheckConstraint("{{ check.expression | replace('"', '\\"') }}", name="{{ check.name }}"),
|
|
218
232
|
{% endfor %}
|
|
233
|
+
{% for constraint in table.unique_constraints %}
|
|
234
|
+
UniqueConstraint(
|
|
235
|
+
{% for c in constraint.columns %}
|
|
236
|
+
"{{ c }}",
|
|
237
|
+
{% endfor %}
|
|
238
|
+
name="{{ constraint.name }}",
|
|
239
|
+
{% if constraint.nulls_not_distinct %}
|
|
240
|
+
postgresql_nulls_not_distinct=True,
|
|
241
|
+
{% endif %}
|
|
242
|
+
),
|
|
243
|
+
{% endfor %}
|
|
219
244
|
{% for idx in table.indexes %}
|
|
220
245
|
{% if idx.where and idx.unique %}
|
|
221
246
|
Index(
|
|
@@ -282,6 +307,9 @@ class {{ table.class_name }}({{ base_class }}):
|
|
|
282
307
|
{% if col.is_pk -%}
|
|
283
308
|
{% set _ = col_args.append('primary_key=True') -%}
|
|
284
309
|
{% endif -%}
|
|
310
|
+
{% if col.disable_autoincrement -%}
|
|
311
|
+
{% set _ = col_args.append('autoincrement=False') -%}
|
|
312
|
+
{% endif -%}
|
|
285
313
|
{% if col.is_unique -%}
|
|
286
314
|
{% set _ = col_args.append('unique=True') -%}
|
|
287
315
|
{% endif -%}
|
package/bin/dbspec/dbspec.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED