comdab 0.1.1__tar.gz → 0.2.0__tar.gz
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.
- comdab-0.2.0/CHANGELOG.md +25 -0
- {comdab-0.1.1 → comdab-0.2.0}/PKG-INFO +7 -7
- {comdab-0.1.1 → comdab-0.2.0}/README.md +6 -6
- {comdab-0.1.1 → comdab-0.2.0}/docs/index.rst +1 -1
- {comdab-0.1.1 → comdab-0.2.0}/pyproject.toml +1 -1
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/compare.py +37 -42
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/specific/postgresql/exclude_constraints.py +3 -6
- {comdab-0.1.1 → comdab-0.2.0}/tests/test_compare.py +5 -1
- {comdab-0.1.1 → comdab-0.2.0}/uv.lock +1 -1
- {comdab-0.1.1 → comdab-0.2.0}/.github/workflows/release.yml +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/.github/workflows/test.yml +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/.gitignore +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/.pre-commit-config.yaml +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/.python-version +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/.readthedocs.yaml +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/LICENSE +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/docs/Makefile +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/docs/conf.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/docs/reference.rst +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/__init__.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/build.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/exceptions.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/main.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/__init__.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/base.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/column.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/constraint.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/function.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/index.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/schema.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/sequence.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/table.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/trigger.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/type.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/models/view.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/path.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/py.typed +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/report.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/source.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/specific/__init__.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/specific/postgresql/__init__.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/specific/postgresql/build.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/specific/postgresql/functions.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/specific/postgresql/sequences.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/specific/postgresql/triggers.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/specific/postgresql/views.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/src/comdab/utils.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/tests/__init__.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/tests/_mock_module.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/tests/conftest.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/tests/test_build.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/tests/test_main.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/tests/test_models.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/tests/test_specific/__init__.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/tests/test_specific/test_postgresql.py +0 -0
- {comdab-0.1.1 → comdab-0.2.0}/tests/test_utils.py +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.0] - 2025-07-23
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Ignore rules aimed at specific dictionary key(s) now also apply to matching keys that are only in the left
|
|
13
|
+
or only in the right dictionaries, in addition to `.left_only` / `.right_only` rules
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- PostgreSQL exclude constraints attributes and operators were sometime mixed
|
|
18
|
+
|
|
19
|
+
## [0.1.1] - 2025-06-22
|
|
20
|
+
|
|
21
|
+
- Fixed PyPI metadata and other non-code changes
|
|
22
|
+
|
|
23
|
+
## [0.1.0] - 2025-06-22
|
|
24
|
+
|
|
25
|
+
Initial version
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: comdab
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Compare Database Schemas
|
|
5
5
|
Project-URL: Homepage, https://github.com/loic-simon/comdab
|
|
6
6
|
Project-URL: Documentation, https://comdab.readthedocs.io/en/latest
|
|
@@ -23,10 +23,10 @@ Description-Content-Type: text/markdown
|
|
|
23
23
|
|
|
24
24
|
# comdab — Compare Database Schemas
|
|
25
25
|
|
|
26
|
-

|
|
27
|
-

|
|
28
|
-

|
|
29
|
-

|
|
26
|
+
[](https://pypi.org/p/comdab)
|
|
27
|
+
[](https://pypi.org/p/comdab)
|
|
28
|
+
[](https://github.com/loic-simon/comdab/actions/workflows/test.yml)
|
|
29
|
+
[](https://comdab.readthedocs.io)
|
|
30
30
|

|
|
31
31
|
|
|
32
32
|
_comdab_ allows you to compare in depth two database schemas to find
|
|
@@ -93,7 +93,7 @@ else:
|
|
|
93
93
|
print("✅ Database schemas are the same!")
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
See documentation for configuration and other details.
|
|
96
|
+
See [documentation](https://comdab.readthedocs.io) for configuration and other details.
|
|
97
97
|
|
|
98
98
|
## Contributing
|
|
99
99
|
|
|
@@ -101,6 +101,6 @@ Issues and pull requests are welcome!
|
|
|
101
101
|
|
|
102
102
|
## License
|
|
103
103
|
|
|
104
|
-
This work is shared under [the MIT license](LICENSE)
|
|
104
|
+
This work is shared under [the MIT license](LICENSE).
|
|
105
105
|
|
|
106
106
|
@ 2025 Loïc Simon ([loic.simon@espci.org](mailto:loic.simon@espci.org))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# comdab — Compare Database Schemas
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-

|
|
3
|
+
[](https://pypi.org/p/comdab)
|
|
4
|
+
[](https://pypi.org/p/comdab)
|
|
5
|
+
[](https://github.com/loic-simon/comdab/actions/workflows/test.yml)
|
|
6
|
+
[](https://comdab.readthedocs.io)
|
|
7
7
|

|
|
8
8
|
|
|
9
9
|
_comdab_ allows you to compare in depth two database schemas to find
|
|
@@ -70,7 +70,7 @@ else:
|
|
|
70
70
|
print("✅ Database schemas are the same!")
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
See documentation for configuration and other details.
|
|
73
|
+
See [documentation](https://comdab.readthedocs.io) for configuration and other details.
|
|
74
74
|
|
|
75
75
|
## Contributing
|
|
76
76
|
|
|
@@ -78,6 +78,6 @@ Issues and pull requests are welcome!
|
|
|
78
78
|
|
|
79
79
|
## License
|
|
80
80
|
|
|
81
|
-
This work is shared under [the MIT license](LICENSE)
|
|
81
|
+
This work is shared under [the MIT license](LICENSE).
|
|
82
82
|
|
|
83
83
|
@ 2025 Loïc Simon ([loic.simon@espci.org](mailto:loic.simon@espci.org))
|
|
@@ -158,7 +158,7 @@ may override a more general exclusion:
|
|
|
158
158
|
ROOT.tables[...].columns.right_only: "warning",
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
Rules can use regular expressions, but two rules *cannot* match
|
|
161
|
+
Rules can use regular expressions, but two rules *cannot* match a same object:
|
|
162
162
|
if you want to say "every tables but ``foo``", use ``(?!foo$).*``.
|
|
163
163
|
|
|
164
164
|
|
|
@@ -117,63 +117,58 @@ class ComdabComparer:
|
|
|
117
117
|
left_dict = cast(dict[str, Any], left_attr)
|
|
118
118
|
right_dict = cast(dict[str, Any], right_attr)
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
left_only = [key for key in left_dict if key not in right_dict]
|
|
122
|
-
right_only = [key for key in right_dict if key not in left_dict]
|
|
123
|
-
both = [key for key in left_dict if key in right_dict]
|
|
120
|
+
all_keys = sorted(left_dict | right_dict)
|
|
124
121
|
key_depth = field_depth + 1
|
|
125
122
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
left_only_crule = next(
|
|
124
|
+
(rule for rule in field_prules if rule.get_attr_component(key_depth) == "left_only"), None
|
|
125
|
+
)
|
|
126
|
+
right_only_crule = next(
|
|
127
|
+
(rule for rule in field_prules if rule.get_attr_component(key_depth) == "right_only"), None
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
for key in all_keys:
|
|
131
|
+
# Key in both dicts: compare, using the matching rule, else field rule
|
|
132
|
+
key_prules = [rule for rule in field_prules if _regex_applies(rule.get_item_component(key_depth), key)]
|
|
133
|
+
key_crules = [rule for rule in key_prules if rule.applies_to(key_depth)]
|
|
134
|
+
if len(key_crules) > 1:
|
|
135
|
+
raise OverlappingPathsError(
|
|
136
|
+
f"The key {key!r} matches more than one regex: "
|
|
137
|
+
f"{', '.join(r.get_item_component(key_depth) or '?' for r in key_crules)}"
|
|
138
|
+
)
|
|
139
|
+
key_crule = key_crules[0] if key_crules else None
|
|
140
|
+
|
|
141
|
+
if key not in right_dict:
|
|
142
|
+
# Keys only in left dict: apply special rule, else the rule matching the key, else field rule
|
|
143
|
+
key_crule = left_only_crule or key_crule or field_crule
|
|
144
|
+
if key_crule.strategy != "ignore":
|
|
134
145
|
yield ComdabReport(
|
|
135
|
-
level=
|
|
146
|
+
level=key_crule.strategy,
|
|
136
147
|
path=field_path.left_only,
|
|
137
148
|
left={key: left_dict[key]},
|
|
138
149
|
right={},
|
|
139
150
|
)
|
|
140
151
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
field_crule,
|
|
146
|
-
)
|
|
147
|
-
if right_only_crule.strategy != "ignore":
|
|
148
|
-
for key in right_only:
|
|
152
|
+
elif key not in left_dict:
|
|
153
|
+
# Keys only in right dict: apply special rule, else the rule matching the key, else field rule
|
|
154
|
+
key_crule = right_only_crule or key_crule or field_crule
|
|
155
|
+
if key_crule.strategy != "ignore":
|
|
149
156
|
yield ComdabReport(
|
|
150
|
-
level=
|
|
157
|
+
level=key_crule.strategy,
|
|
151
158
|
path=field_path.right_only,
|
|
152
159
|
left={},
|
|
153
160
|
right={key: right_dict[key]},
|
|
154
161
|
)
|
|
155
162
|
|
|
156
|
-
for key in both:
|
|
157
|
-
# Key in both dicts: compare, using the matching rule, else field rule
|
|
158
|
-
key_prules = [rule for rule in field_prules if _regex_applies(rule.get_item_component(key_depth), key)]
|
|
159
|
-
key_crules = [rule for rule in key_prules if rule.applies_to(key_depth)]
|
|
160
|
-
if len(key_crules) > 1:
|
|
161
|
-
raise OverlappingPathsError(
|
|
162
|
-
f"The key {key!r} matches more than one regex: "
|
|
163
|
-
f"{', '.join(r.get_item_component(key_depth) or '?' for r in key_crules)}"
|
|
164
|
-
)
|
|
165
|
-
elif key_crules:
|
|
166
|
-
key_crule = key_crules[0]
|
|
167
163
|
else:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
164
|
+
# Key in both dicts: compare, using the matching rule, else field rule
|
|
165
|
+
yield from self._compare(
|
|
166
|
+
left_dict[key],
|
|
167
|
+
right_dict[key],
|
|
168
|
+
path=field_path[key],
|
|
169
|
+
crule=key_crule or field_crule,
|
|
170
|
+
prules=key_prules,
|
|
171
|
+
)
|
|
177
172
|
|
|
178
173
|
|
|
179
174
|
def _regex_applies(pattern: str | None, key: str) -> bool:
|
|
@@ -41,13 +41,10 @@ _EXCLUDE_CONSTRAINTS_QUERY = typed_sql[_ExcludeConstraintsQuery](
|
|
|
41
41
|
GROUP BY con2.oid, ind.indexrelid, am.oid
|
|
42
42
|
) ix_info ON ix_info.oid = con.oid
|
|
43
43
|
JOIN (
|
|
44
|
-
SELECT con3.oid, ARRAY_AGG(opr.oprname) AS operators
|
|
44
|
+
SELECT con3.oid, ARRAY_AGG(opr.oprname ORDER BY opnum ASC) AS operators
|
|
45
45
|
FROM pg_catalog.pg_constraint con3
|
|
46
|
-
JOIN (
|
|
47
|
-
|
|
48
|
-
FROM pg_catalog.pg_constraint con4
|
|
49
|
-
) con_ops ON con_ops.oid = con3.oid
|
|
50
|
-
JOIN pg_operator opr ON opr.oid = con_ops.opid -- Operator info
|
|
46
|
+
JOIN unnest(con3.conexclop) WITH ORDINALITY AS t(opid, opnum) ON true -- Constraint operators for each column
|
|
47
|
+
JOIN pg_operator opr ON opr.oid = opid -- Operator info
|
|
51
48
|
GROUP BY con3.oid
|
|
52
49
|
) op_info ON op_info.oid = con.oid
|
|
53
50
|
WHERE nsp.nspname = :schema_name
|
|
@@ -289,9 +289,13 @@ def test_rules_empty_vs_full() -> None:
|
|
|
289
289
|
ComdabReport("error", ROOT.views.right_only, {}, {"_table1_mat": FULL_SCHEMA.views["_table1_mat"]}),
|
|
290
290
|
]
|
|
291
291
|
assert _test({ROOT.tables["table1"]: "warning"})[:2] == [
|
|
292
|
-
ComdabReport("
|
|
292
|
+
ComdabReport("warning", ROOT.tables.right_only, {}, {"table1": FULL_SCHEMA.tables["table1"]}),
|
|
293
293
|
ComdabReport("error", ROOT.tables.right_only, {}, {"table2": FULL_SCHEMA.tables["table2"]}),
|
|
294
294
|
]
|
|
295
|
+
assert _test({ROOT.tables[".+2"]: "warning"})[:2] == [
|
|
296
|
+
ComdabReport("error", ROOT.tables.right_only, {}, {"table1": FULL_SCHEMA.tables["table1"]}),
|
|
297
|
+
ComdabReport("warning", ROOT.tables.right_only, {}, {"table2": FULL_SCHEMA.tables["table2"]}),
|
|
298
|
+
]
|
|
295
299
|
|
|
296
300
|
# just to test left_only too
|
|
297
301
|
assert ComdabComparer(rules={ROOT.tables.left_only: "warning"}).compare(FULL_SCHEMA, EMPTY_SCHEMA)[:2] == [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|