details: https://code.tryton.org/tryton/commit/f730392a2701
branch: default
user: Cédric Krier <[email protected]>
date: Mon Aug 17 15:06:09 2026 +0200
description:
Limit the start id of table to 500 for tests
By using the formula `(idx * prime) % range + 1`, tables created
consecutively
have start id distant by `prime` and the maximum start id is `range`.
This avoid to overflow int4 when composing unique ID for table query.
Closes #15010
diffstat:
trytond/trytond/model/modelsql.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diffs (26 lines):
diff -r a9482f843bf5 -r f730392a2701 trytond/trytond/model/modelsql.py
--- a/trytond/trytond/model/modelsql.py Sat Jul 04 11:41:01 2026 +0200
+++ b/trytond/trytond/model/modelsql.py Mon Aug 17 15:06:09 2026 +0200
@@ -510,10 +510,12 @@
table = cls.__table_handler__(module_name)
if Pool.test:
from trytond.tests import TABLES_CREATED
+ range_ = 500
+ prime = 101 # coprime of 500
if cls._table not in TABLES_CREATED:
database.setnextid(
transaction.connection, cls._table,
- len(TABLES_CREATED) * 500 + 1)
+ (len(TABLES_CREATED) * prime) % range_ + 1)
TABLES_CREATED.add(cls._table)
if cls._history:
@@ -524,7 +526,7 @@
if table_history not in TABLES_CREATED:
database.setnextid(
transaction.connection, table_history,
- len(TABLES_CREATED) * 500 + 1)
+ (len(TABLES_CREATED) * prime) % range_ + 1)
TABLES_CREATED.add(table_history)
for field_name, field in cls._fields.items():