From 941a2b4246b5649016b67dbf1eea18f1ed830607 Mon Sep 17 00:00:00 2001 From: Edoardo Piroli Date: Tue, 29 Oct 2024 15:13:28 +0100 Subject: [PATCH] [IMP] tests: only persistent table must have a primary key In some cases, it can be handy to define an unlogged/temporary table to memontarily store information from before the upgrade. We don't care for such non persistent tables to have a primary key. --- src/base/tests/test_ensure_has_pk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/base/tests/test_ensure_has_pk.py b/src/base/tests/test_ensure_has_pk.py index 764b2e60..df5e992f 100644 --- a/src/base/tests/test_ensure_has_pk.py +++ b/src/base/tests/test_ensure_has_pk.py @@ -20,6 +20,7 @@ def invariant(self): JOIN pg_namespace ns on ns.oid = c.relnamespace LEFT JOIN pg_constraint p on p.conrelid = c.oid and p.contype = 'p' WHERE c.relkind IN ('r', 'p') + AND c.relpersistence = 'p' AND ns.nspname = current_schema AND p.oid IS NULL ORDER BY c.relname @@ -28,7 +29,7 @@ def invariant(self): cr.execute(query) if cr.rowcount: tables = "\n".join(" - %s" % t for (t,) in cr.fetchall()) - msg = "Some tables doesn't have any primary key:\n{}".format(tables) + msg = "Some tables don't have any primary key:\n{}".format(tables) _logger.critical(msg) if util.on_CI(): raise AssertionError(msg)