comdab 0.3.0__tar.gz → 0.3.1__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.
Files changed (59) hide show
  1. {comdab-0.3.0 → comdab-0.3.1}/.github/workflows/test.yml +1 -1
  2. {comdab-0.3.0 → comdab-0.3.1}/.pre-commit-config.yaml +3 -3
  3. {comdab-0.3.0 → comdab-0.3.1}/CHANGELOG.md +6 -0
  4. {comdab-0.3.0 → comdab-0.3.1}/PKG-INFO +1 -1
  5. {comdab-0.3.0 → comdab-0.3.1}/pyproject.toml +6 -3
  6. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/type.py +1 -2
  7. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/specific/postgresql/functions.py +1 -1
  8. {comdab-0.3.0 → comdab-0.3.1}/tests/_mock_module.py +1 -1
  9. {comdab-0.3.0 → comdab-0.3.1}/tests/test_models.py +10 -6
  10. {comdab-0.3.0 → comdab-0.3.1}/tests/test_specific/test_postgresql.py +29 -12
  11. comdab-0.3.1/uv.lock +658 -0
  12. comdab-0.3.0/uv.lock +0 -544
  13. {comdab-0.3.0 → comdab-0.3.1}/.github/workflows/release.yml +0 -0
  14. {comdab-0.3.0 → comdab-0.3.1}/.gitignore +0 -0
  15. {comdab-0.3.0 → comdab-0.3.1}/.python-version +0 -0
  16. {comdab-0.3.0 → comdab-0.3.1}/.readthedocs.yaml +0 -0
  17. {comdab-0.3.0 → comdab-0.3.1}/LICENSE +0 -0
  18. {comdab-0.3.0 → comdab-0.3.1}/README.md +0 -0
  19. {comdab-0.3.0 → comdab-0.3.1}/docs/Makefile +0 -0
  20. {comdab-0.3.0 → comdab-0.3.1}/docs/conf.py +0 -0
  21. {comdab-0.3.0 → comdab-0.3.1}/docs/index.rst +0 -0
  22. {comdab-0.3.0 → comdab-0.3.1}/docs/reference.rst +0 -0
  23. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/__init__.py +0 -0
  24. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/build.py +0 -0
  25. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/compare.py +0 -0
  26. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/exceptions.py +0 -0
  27. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/main.py +0 -0
  28. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/__init__.py +0 -0
  29. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/base.py +0 -0
  30. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/column.py +0 -0
  31. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/constraint.py +0 -0
  32. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/custom_type.py +0 -0
  33. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/function.py +0 -0
  34. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/index.py +0 -0
  35. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/schema.py +0 -0
  36. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/sequence.py +0 -0
  37. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/table.py +0 -0
  38. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/trigger.py +0 -0
  39. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/models/view.py +0 -0
  40. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/path.py +0 -0
  41. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/py.typed +0 -0
  42. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/report.py +0 -0
  43. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/source.py +0 -0
  44. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/specific/__init__.py +0 -0
  45. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/specific/postgresql/__init__.py +0 -0
  46. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/specific/postgresql/build.py +0 -0
  47. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/specific/postgresql/custom_types.py +0 -0
  48. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/specific/postgresql/exclude_constraints.py +0 -0
  49. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/specific/postgresql/sequences.py +0 -0
  50. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/specific/postgresql/triggers.py +0 -0
  51. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/specific/postgresql/views.py +0 -0
  52. {comdab-0.3.0 → comdab-0.3.1}/src/comdab/utils.py +0 -0
  53. {comdab-0.3.0 → comdab-0.3.1}/tests/__init__.py +0 -0
  54. {comdab-0.3.0 → comdab-0.3.1}/tests/conftest.py +0 -0
  55. {comdab-0.3.0 → comdab-0.3.1}/tests/test_build.py +0 -0
  56. {comdab-0.3.0 → comdab-0.3.1}/tests/test_compare.py +0 -0
  57. {comdab-0.3.0 → comdab-0.3.1}/tests/test_main.py +0 -0
  58. {comdab-0.3.0 → comdab-0.3.1}/tests/test_specific/__init__.py +0 -0
  59. {comdab-0.3.0 → comdab-0.3.1}/tests/test_utils.py +0 -0
@@ -11,7 +11,7 @@ jobs:
11
11
  python-version:
12
12
  - "3.12"
13
13
  - "3.13"
14
- - "3.14.0-beta.3"
14
+ - "3.14.0-rc.2"
15
15
 
16
16
  steps:
17
17
  - uses: actions/checkout@v4
@@ -1,6 +1,6 @@
1
1
  repos:
2
2
  - repo: https://github.com/pre-commit/pre-commit-hooks
3
- rev: v3.2.0
3
+ rev: v6.0.0
4
4
  hooks:
5
5
  - id: trailing-whitespace
6
6
  - id: end-of-file-fixer
@@ -8,14 +8,14 @@ repos:
8
8
  - id: check-added-large-files
9
9
 
10
10
  - repo: https://github.com/astral-sh/ruff-pre-commit
11
- rev: v0.11.11
11
+ rev: v0.15.9
12
12
  hooks:
13
13
  - id: ruff
14
14
  args: ["--fix"]
15
15
  - id: ruff-format
16
16
 
17
17
  - repo: https://github.com/RobertCraigie/pyright-python
18
- rev: v1.1.402
18
+ rev: v1.1.408
19
19
  hooks:
20
20
  - id: pyright
21
21
  hook-stage: pre-push
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.1] - 2026-04-07
9
+
10
+ ### Added
11
+
12
+ - PostgreSQL: detect & compare procedures, in addition of regular functions
13
+
8
14
  ## [0.3.0] - 2025-08-12
9
15
 
10
16
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: comdab
3
- Version: 0.3.0
3
+ Version: 0.3.1
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "comdab"
3
- version = "0.3.0"
3
+ version = "0.3.1"
4
4
  description = "Compare Database Schemas"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -27,8 +27,8 @@ Issues = "https://github.com/loic-simon/comdab/issues"
27
27
  requires = ["hatchling >= 1.26"]
28
28
  build-backend = "hatchling.build"
29
29
 
30
- [tool.uv]
31
- dev-dependencies = [
30
+ [dependency-groups]
31
+ dev = [
32
32
  "psycopg2>=2.9.10",
33
33
  "pytest>=8.4.0",
34
34
  "ruff>=0.11.11",
@@ -38,6 +38,9 @@ dev-dependencies = [
38
38
  [tool.ruff]
39
39
  line-length = 120
40
40
 
41
+ [tool.ruff.lint]
42
+ select = ["E", "F", "UP", "B", "SIM", "I"]
43
+
41
44
  [tool.pyright]
42
45
  typeCheckingMode = "strict"
43
46
  venvPath = "."
@@ -1,7 +1,6 @@
1
- from typing import Any, get_args
1
+ from typing import Any, Unpack, get_args
2
2
 
3
3
  from pydantic import ConfigDict, Field
4
- from typing_extensions import Unpack
5
4
 
6
5
  from comdab.models.base import ComdabModel
7
6
  from comdab.path import (
@@ -19,7 +19,7 @@ _FUNCTIONS_QUERY = typed_sql[_FunctionsQuery](
19
19
  JOIN pg_catalog.pg_namespace nsp ON nsp.oid = pro.pronamespace -- Function schema
20
20
  JOIN pg_catalog.pg_language lan ON lan.oid = pro.prolang -- Function implementation language
21
21
  WHERE nsp.nspname = :schema_name
22
- AND pro.prokind = 'f' -- TODO: handle procedure/aggregate/window functions?
22
+ AND pro.prokind IN ('f', 'p') -- TODO: handle aggregate/window functions?
23
23
  AND lan.lanname != 'c';
24
24
  """,
25
25
  )
@@ -2,6 +2,6 @@ from functools import lru_cache
2
2
  from unittest.mock import Mock
3
3
 
4
4
 
5
- @lru_cache()
5
+ @lru_cache
6
6
  def __getattr__(item: object) -> Mock:
7
7
  return Mock()
@@ -82,7 +82,7 @@ class TestPathsConsistency:
82
82
  try:
83
83
  Path = cast(type[ComdabPath], base_schema_field.Path) # pyright: ignore
84
84
  except AttributeError:
85
- raise AssertionError(f"Missing Path attribute for ComdabModel: {base_schema_field}")
85
+ raise AssertionError(f"Missing Path attribute for ComdabModel: {base_schema_field}") from None
86
86
  assert path_type is Path, (
87
87
  f"{base_model.__name__}.Path.{name} describes a {path_type}, expected {base_schema_field}.Path!"
88
88
  )
@@ -102,12 +102,14 @@ class TestPathsConsistency:
102
102
  try:
103
103
  Path = cast(type[ComdabPath], base_value_ann.Path) # pyright: ignore
104
104
  except AttributeError:
105
- raise AssertionError(f"Missing Path attribute for ComdabModel: {base_value_ann}")
105
+ raise AssertionError(f"Missing Path attribute for ComdabModel: {base_value_ann}") from None
106
106
  assert get_origin(path_type) is ComdabPathDict, (
107
- f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary of {base_schema_field}.Path!"
107
+ f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary "
108
+ f"of {base_schema_field}.Path!"
108
109
  )
109
110
  assert get_args(path_type)[0] is Path, (
110
- f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary of {base_schema_field}.Path!"
111
+ f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary "
112
+ f"of {base_schema_field}.Path!"
111
113
  )
112
114
 
113
115
  # Then validate child schema
@@ -117,10 +119,12 @@ class TestPathsConsistency:
117
119
  else:
118
120
  # Schema field is a dict of non-schemas: check the path field is a dict of terminal ComdabPaths
119
121
  assert get_origin(path_type) is ComdabPathDict, (
120
- f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary of ComdabPath!"
122
+ f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary "
123
+ "of ComdabPath!"
121
124
  )
122
125
  assert get_args(path_type)[0] is ComdabPath, (
123
- f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary of ComdabPath!"
126
+ f"{base_model.__name__}.Path.{name} describes a {path_type}, expected a dictionary "
127
+ "of ComdabPath!"
124
128
  )
125
129
 
126
130
  case _:
@@ -103,22 +103,22 @@ def test_psql_views(meta: MetaData, connection: Connection) -> None:
103
103
  assert builder.build_schema().views == {
104
104
  "_view_1": ComdabView(
105
105
  name="_view_1",
106
- definition="SELECT table_1.id,\n ((table_1.name)::text || table_1.id) AS name_and_id\n FROM table_1;",
106
+ definition="SELECT id,\n ((name)::text || id) AS name_and_id\n FROM table_1;",
107
107
  materialized=False,
108
108
  ),
109
109
  "_view_2": ComdabView(
110
110
  name="_view_2",
111
- definition="SELECT table_1.id,\n ((table_1.id * 2) || (table_1.name)::text) AS id_and_name\n FROM table_1;",
111
+ definition="SELECT id,\n ((id * 2) || (name)::text) AS id_and_name\n FROM table_1;",
112
112
  materialized=False,
113
113
  ),
114
114
  "_view_3": ComdabView(
115
115
  name="_view_3",
116
- definition="SELECT table_1.id,\n ((table_1.name)::text || (table_1.id * 3)) AS name_and_id\n FROM table_1;",
116
+ definition="SELECT id,\n ((name)::text || (id * 3)) AS name_and_id\n FROM table_1;",
117
117
  materialized=True,
118
118
  ),
119
119
  "_view_4": ComdabView(
120
120
  name="_view_4",
121
- definition="SELECT table_1.id,\n ((table_1.id * 4) || (table_1.name)::text) AS id_and_name\n FROM table_1;",
121
+ definition="SELECT id,\n ((id * 4) || (name)::text) AS id_and_name\n FROM table_1;",
122
122
  materialized=True,
123
123
  ),
124
124
  }
@@ -173,6 +173,7 @@ def test_psql_functions(meta: MetaData, connection: Connection) -> None:
173
173
  connection.exec_driver_sql(
174
174
  "CREATE OR REPLACE FUNCTION public._huh() RETURNS integer AS $fbd$ SELECT 42;$fbd$ LANGUAGE sql;"
175
175
  )
176
+ connection.exec_driver_sql("CREATE OR REPLACE PROCEDURE public._proc() AS $fbd$ SELECT 42;$fbd$ LANGUAGE sql;")
176
177
  connection.exec_driver_sql("CREATE SCHEMA other;")
177
178
  connection.exec_driver_sql(
178
179
  "CREATE OR REPLACE FUNCTION other._huh() RETURNS integer AS $fbd$ SELECT 43;$fbd$ LANGUAGE sql;"
@@ -182,11 +183,20 @@ def test_psql_functions(meta: MetaData, connection: Connection) -> None:
182
183
  assert builder.build_schema().functions == {
183
184
  "day_range": ComdabFunction(
184
185
  name="day_range",
185
- definition="CREATE OR REPLACE FUNCTION public.day_range(start_date date, end_date date)\n RETURNS SETOF date\n LANGUAGE sql\n IMMUTABLE PARALLEL SAFE\nAS $function$\n SELECT day::date\n FROM generate_series(start_date, end_date, '1 day'::interval) day\n $function$\n",
186
+ definition="CREATE OR REPLACE FUNCTION public.day_range(start_date date, end_date date)\n "
187
+ "RETURNS SETOF date\n LANGUAGE sql\n IMMUTABLE PARALLEL SAFE\nAS $function$\n "
188
+ "SELECT day::date\n FROM generate_series(start_date, end_date, '1 day'::interval) day\n "
189
+ "$function$\n",
186
190
  ),
187
191
  "_huh": ComdabFunction(
188
192
  name="_huh",
189
- definition="CREATE OR REPLACE FUNCTION public._huh()\n RETURNS integer\n LANGUAGE sql\nAS $function$ SELECT 42;$function$\n",
193
+ definition="CREATE OR REPLACE FUNCTION public._huh()\n RETURNS integer\n LANGUAGE sql\nAS $function$ "
194
+ "SELECT 42;$function$\n",
195
+ ),
196
+ "_proc": ComdabFunction(
197
+ name="_proc",
198
+ definition="CREATE OR REPLACE PROCEDURE public._proc()\n LANGUAGE sql\nAS $procedure$ "
199
+ "SELECT 42;$procedure$\n",
190
200
  ),
191
201
  }
192
202
 
@@ -194,7 +204,8 @@ def test_psql_functions(meta: MetaData, connection: Connection) -> None:
194
204
  assert other_builder.build_schema().functions == {
195
205
  "_huh": ComdabFunction(
196
206
  name="_huh",
197
- definition="CREATE OR REPLACE FUNCTION other._huh()\n RETURNS integer\n LANGUAGE sql\nAS $function$ SELECT 43;$function$\n",
207
+ definition="CREATE OR REPLACE FUNCTION other._huh()\n RETURNS integer\n LANGUAGE sql\nAS $function$ "
208
+ "SELECT 43;$function$\n",
198
209
  ),
199
210
  }
200
211
 
@@ -545,12 +556,14 @@ def test_psql_triggers(meta: MetaData, meta_other: MetaData, connection: Connect
545
556
  triggers={
546
557
  "_on_table_1_create": ComdabTrigger(
547
558
  name="_on_table_1_create",
548
- definition="CREATE TRIGGER _on_table_1_create BEFORE INSERT ON public.table_1 FOR EACH ROW EXECUTE FUNCTION _update_name()",
559
+ definition="CREATE TRIGGER _on_table_1_create BEFORE INSERT ON public.table_1 FOR EACH ROW "
560
+ "EXECUTE FUNCTION _update_name()",
549
561
  extra={},
550
562
  ),
551
563
  "_on_table_1_update": ComdabTrigger(
552
564
  name="_on_table_1_update",
553
- definition="CREATE TRIGGER _on_table_1_update BEFORE UPDATE ON public.table_1 FOR EACH ROW EXECUTE FUNCTION _update_name()",
565
+ definition="CREATE TRIGGER _on_table_1_update BEFORE UPDATE ON public.table_1 FOR EACH ROW "
566
+ "EXECUTE FUNCTION _update_name()",
554
567
  extra={},
555
568
  ),
556
569
  },
@@ -592,7 +605,8 @@ def test_psql_triggers(meta: MetaData, meta_other: MetaData, connection: Connect
592
605
  triggers={
593
606
  "_on_table_2_create_or_update": ComdabTrigger(
594
607
  name="_on_table_2_create_or_update",
595
- definition="CREATE TRIGGER _on_table_2_create_or_update BEFORE INSERT OR UPDATE ON public.table_2 FOR EACH ROW EXECUTE FUNCTION _update_name()",
608
+ definition="CREATE TRIGGER _on_table_2_create_or_update BEFORE INSERT OR UPDATE "
609
+ "ON public.table_2 FOR EACH ROW EXECUTE FUNCTION _update_name()",
596
610
  extra={},
597
611
  )
598
612
  },
@@ -625,7 +639,9 @@ def test_psql_triggers(meta: MetaData, meta_other: MetaData, connection: Connect
625
639
  functions={
626
640
  "_update_name": ComdabFunction(
627
641
  name="_update_name",
628
- definition="CREATE OR REPLACE FUNCTION public._update_name()\n RETURNS trigger\n LANGUAGE plpgsql\nAS $function$\n BEGIN\n NEW.name := NEW.name || '!';\n RETURN NEW;\n END;\n $function$\n",
642
+ definition="CREATE OR REPLACE FUNCTION public._update_name()\n RETURNS trigger\n LANGUAGE plpgsql\nAS "
643
+ "$function$\n BEGIN\n NEW.name := NEW.name || '!';\n RETURN NEW;\n "
644
+ "END;\n $function$\n",
629
645
  extra={},
630
646
  )
631
647
  },
@@ -672,7 +688,8 @@ def test_psql_triggers(meta: MetaData, meta_other: MetaData, connection: Connect
672
688
  triggers={
673
689
  "_on_table_1_create": ComdabTrigger(
674
690
  name="_on_table_1_create",
675
- definition="CREATE TRIGGER _on_table_1_create BEFORE INSERT ON other.other_table FOR EACH ROW EXECUTE FUNCTION _update_name()",
691
+ definition="CREATE TRIGGER _on_table_1_create BEFORE INSERT ON other.other_table FOR EACH ROW "
692
+ "EXECUTE FUNCTION _update_name()",
676
693
  extra={},
677
694
  )
678
695
  },