pgdeclare 0.2.0__tar.gz → 0.2.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.
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/CHANGELOG.md +9 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/PKG-INFO +2 -2
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/README.md +1 -1
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/pyproject.toml +1 -1
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/__init__.py +1 -1
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/differ.py +18 -14
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_boundary.py +1 -1
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_expand_contract.py +25 -2
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_routines.py +5 -3
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/.gitignore +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/LICENSE +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/NOTICE +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/__main__.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/changes.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/cli.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/config.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/contract.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/drop_directive.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/executor.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/introspection.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/ledger.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/migrate.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/models.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/prove.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/py.typed +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/quoting.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/retry_executor.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/schema_parser.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/src/pgdeclare/statement_parser.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/conftest.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/dbutil.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_cli.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_comments.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_default_privileges.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_diff.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_domains.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_foreign_data.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_integration.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_lifecycle.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_materialized_views.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_partitions.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_pipeline.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_prove.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_publications_rules.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_ranges_collations.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_retry_executor.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_security.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_sequences.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_statement_parser.py +0 -0
- {pgdeclare-0.2.0 → pgdeclare-0.2.1}/tests/test_views.py +0 -0
|
@@ -5,6 +5,15 @@ All notable changes to this project are documented here. The format follows
|
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). Until 1.0 the API
|
|
6
6
|
may change in minor releases.
|
|
7
7
|
|
|
8
|
+
## [0.2.1] - 2026-11-19
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- A change of a routine's parameter names alone is now offline. The drop and
|
|
13
|
+
re-create is still one statement, but a call that names the old
|
|
14
|
+
parameters (`f(p_old => 1)`) fails from then on, so an application still
|
|
15
|
+
using them must be stopped.
|
|
16
|
+
|
|
8
17
|
## [0.2.0] - 2026-11-19
|
|
9
18
|
|
|
10
19
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pgdeclare
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Declarative Postgres schemas: diff the live database against your SQL files, with before/after migration blocks and a hash ledger.
|
|
5
5
|
Project-URL: Homepage, https://github.com/powertime-org/pgdeclare
|
|
6
6
|
Project-URL: Source, https://github.com/powertime-org/pgdeclare
|
|
@@ -47,7 +47,7 @@ A diff cannot infer everything, such as a rename or a backfill. For those you wr
|
|
|
47
47
|
|
|
48
48
|

|
|
49
49
|
|
|
50
|
-
Status: **0.2.
|
|
50
|
+
Status: **0.2.1.** The engine has run the production schema of [Powertime](https://powertime.org) since it went into service on 10 December 2025. Backwards compatibility may not be preserved until 1.0.
|
|
51
51
|
|
|
52
52
|
## Design choices
|
|
53
53
|
|
|
@@ -14,7 +14,7 @@ A diff cannot infer everything, such as a rename or a backfill. For those you wr
|
|
|
14
14
|
|
|
15
15
|

|
|
16
16
|
|
|
17
|
-
Status: **0.2.
|
|
17
|
+
Status: **0.2.1.** The engine has run the production schema of [Powertime](https://powertime.org) since it went into service on 10 December 2025. Backwards compatibility may not be preserved until 1.0.
|
|
18
18
|
|
|
19
19
|
## Design choices
|
|
20
20
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pgdeclare"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "Declarative Postgres schemas: diff the live database against your SQL files, with before/after migration blocks and a hash ledger."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -1350,28 +1350,32 @@ def _diff_functions(desired: Schema, actual: Schema) -> list[Change]:
|
|
|
1350
1350
|
# The old signature has to go in the same statement, with the
|
|
1351
1351
|
# OLD args so the DROP names what is there. When only the
|
|
1352
1352
|
# parameter names changed the identity is the same, so the
|
|
1353
|
-
# two cannot coexist, and a call
|
|
1353
|
+
# two cannot coexist, and a call that names the old
|
|
1354
|
+
# parameters (`p_old => ...`) fails from the DROP on.
|
|
1354
1355
|
# Otherwise the overloads would compete for some call (a new
|
|
1355
1356
|
# DEFAULT that lets a call of the old length match both is
|
|
1356
|
-
# the usual case: "function ... is not unique"), and
|
|
1357
|
-
#
|
|
1358
|
-
#
|
|
1357
|
+
# the usual case: "function ... is not unique"), and a call
|
|
1358
|
+
# to the old signature fails from the DROP on. Either way an
|
|
1359
|
+
# application still calling the old form breaks: offline.
|
|
1359
1360
|
functions_to_drop_for_rename.add(rename_source.signature)
|
|
1360
|
-
same_identity = _same_call_types(func, rename_source)
|
|
1361
1361
|
change = DropAndCreateFunction(
|
|
1362
1362
|
function=func,
|
|
1363
1363
|
old_args=rename_source.args, # Pass old args for correct DROP
|
|
1364
1364
|
old_kind=rename_source.kind,
|
|
1365
|
+
category=ChangeCategory.OFFLINE,
|
|
1366
|
+
)
|
|
1367
|
+
why = (
|
|
1368
|
+
"a call naming the old parameters fails once it is dropped"
|
|
1369
|
+
if _same_call_types(func, rename_source)
|
|
1370
|
+
else "a call to the old signature fails once it is "
|
|
1371
|
+
"dropped, and the two cannot coexist because a call "
|
|
1372
|
+
"could match both"
|
|
1373
|
+
)
|
|
1374
|
+
change.description = (
|
|
1375
|
+
f"Drop {rename_source.keyword.lower()} "
|
|
1376
|
+
f"{rename_source.signature} and create "
|
|
1377
|
+
f"{func.signature} (offline: {why})"
|
|
1365
1378
|
)
|
|
1366
|
-
if not same_identity:
|
|
1367
|
-
change.category = ChangeCategory.OFFLINE
|
|
1368
|
-
change.description = (
|
|
1369
|
-
f"Drop {rename_source.keyword.lower()} "
|
|
1370
|
-
f"{rename_source.signature} and create "
|
|
1371
|
-
f"{func.signature} (offline: a call to the old "
|
|
1372
|
-
f"signature fails once it is dropped, and the two "
|
|
1373
|
-
f"cannot coexist because a call could match both)"
|
|
1374
|
-
)
|
|
1375
1379
|
changes.append(change)
|
|
1376
1380
|
elif func.definition_hash != actual.functions[key].definition_hash:
|
|
1377
1381
|
# A changed return type or kind requires DROP + CREATE: CREATE OR
|
|
@@ -92,12 +92,14 @@ class TestSignatureChanges:
|
|
|
92
92
|
assert [type(c) for c in changes] == [DropAndCreateFunction]
|
|
93
93
|
assert changes[0].category == ChangeCategory.OFFLINE
|
|
94
94
|
|
|
95
|
-
def
|
|
95
|
+
def test_renamed_parameters_are_one_offline_statement(self):
|
|
96
|
+
# A call in named notation (`total(a => 1)`) fails once `a` is gone.
|
|
96
97
|
old = _fn("total", "a int", "integer", 1, 1)
|
|
97
98
|
new = _fn("total", "amount int", "integer", 1, 1)
|
|
98
99
|
changes = compute_diff(_schema(new), _schema(old))
|
|
99
100
|
assert [type(c) for c in changes] == [DropAndCreateFunction]
|
|
100
|
-
assert changes[0].category == ChangeCategory.
|
|
101
|
+
assert changes[0].category == ChangeCategory.OFFLINE
|
|
102
|
+
assert "naming the old parameters" in changes[0].description
|
|
101
103
|
assert not changes[0].contract
|
|
102
104
|
|
|
103
105
|
def test_an_unknown_call_shape_counts_as_overlapping(self):
|
|
@@ -200,6 +202,27 @@ OLD_CALLS = "SELECT account(gen_random_uuid(), gen_random_uuid()), total(1), gon
|
|
|
200
202
|
|
|
201
203
|
|
|
202
204
|
class TestDeployWhileTheOldVersionServes:
|
|
205
|
+
def test_renamed_parameters_are_refused_online(self, tmp_path, databases):
|
|
206
|
+
target, plan = databases
|
|
207
|
+
sql_dir = tmp_path / "sql"
|
|
208
|
+
_declare(sql_dir, V1)
|
|
209
|
+
apply_declared_schema(target, sql_dir, plan, config=QUIET)
|
|
210
|
+
|
|
211
|
+
_declare(
|
|
212
|
+
sql_dir,
|
|
213
|
+
V1.replace(
|
|
214
|
+
"total(a int) RETURNS int LANGUAGE sql AS 'SELECT a'",
|
|
215
|
+
"total(amount int) RETURNS int LANGUAGE sql AS 'SELECT amount'",
|
|
216
|
+
),
|
|
217
|
+
)
|
|
218
|
+
with pytest.raises(Exception, match="Migration execution failed"):
|
|
219
|
+
apply_declared_schema(target, sql_dir, plan, expand_only=True, config=QUIET)
|
|
220
|
+
# The serving version's named call still resolves.
|
|
221
|
+
assert _run(target, "SELECT total(a => 4)") == [(4,)]
|
|
222
|
+
|
|
223
|
+
apply_declared_schema(target, sql_dir, plan, offline=True, config=QUIET)
|
|
224
|
+
assert _run(target, "SELECT total(amount => 4)") == [(4,)]
|
|
225
|
+
|
|
203
226
|
def test_a_new_default_parameter_is_refused_online(self, tmp_path, databases):
|
|
204
227
|
target, plan = databases
|
|
205
228
|
sql_dir = tmp_path / "sql"
|
|
@@ -407,14 +407,16 @@ class TestRoutineRoundTrip:
|
|
|
407
407
|
.replace("'SELECT a + b'", "'SELECT x + y'")
|
|
408
408
|
)
|
|
409
409
|
# The new procedure signature competes with the old one for a call
|
|
410
|
-
# of two arguments,
|
|
410
|
+
# of two arguments, and `step`'s renamed parameters break a call
|
|
411
|
+
# naming the old ones, so both swaps are offline.
|
|
411
412
|
offline = [
|
|
412
413
|
c
|
|
413
414
|
for c in _plan(sql_dir, recreated, target_url, plan_db)
|
|
414
415
|
if c.category.value == "offline"
|
|
415
416
|
]
|
|
416
|
-
assert
|
|
417
|
-
"public.book(IN amount bigint, INOUT booked bigint)"
|
|
417
|
+
assert sorted(c.object_name for c in offline) == [
|
|
418
|
+
"public.book(IN amount bigint, INOUT booked bigint)",
|
|
419
|
+
"public.step(x integer, y integer)",
|
|
418
420
|
]
|
|
419
421
|
_apply(sql_dir, recreated, target_url, plan_db, offline=True)
|
|
420
422
|
routines = _routines(target_url)
|
|
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
|