Reset TABLES_CREATED when dropping the database when testing
Closes #15002 (grafted from e9f2b42e96ebb4553ef153f1d778c5d1042b3891) --HG-- branch : 8.0
This commit is contained in:
@@ -302,7 +302,6 @@ def apply_sorting(keywords):
|
||||
return lambda col: NullOrdering(Order(col))
|
||||
|
||||
|
||||
_TABLES_CREATED = set()
|
||||
_TABLE_QUERY_COLUMNS = {
|
||||
'create_uid': Literal(0),
|
||||
'create_date': CurrentTimestamp(),
|
||||
@@ -509,20 +508,24 @@ class ModelSQL(ModelStorage):
|
||||
|
||||
# create/update table in the database
|
||||
table = cls.__table_handler__(module_name)
|
||||
if Pool.test and cls._table not in _TABLES_CREATED:
|
||||
database.setnextid(
|
||||
transaction.connection, cls._table,
|
||||
len(_TABLES_CREATED) * 500 + 1)
|
||||
_TABLES_CREATED.add(cls._table)
|
||||
if Pool.test:
|
||||
from trytond.tests import TABLES_CREATED
|
||||
if cls._table not in TABLES_CREATED:
|
||||
database.setnextid(
|
||||
transaction.connection, cls._table,
|
||||
len(TABLES_CREATED) * 500 + 1)
|
||||
TABLES_CREATED.add(cls._table)
|
||||
|
||||
if cls._history:
|
||||
history_table = cls.__table_handler__(module_name, history=True)
|
||||
table_history = f'{cls._table}__history'
|
||||
if Pool.test and table_history not in _TABLES_CREATED:
|
||||
database.setnextid(
|
||||
transaction.connection, table_history,
|
||||
len(_TABLES_CREATED) * 500 + 1)
|
||||
_TABLES_CREATED.add(table_history)
|
||||
if Pool.test:
|
||||
from trytond.tests import TABLES_CREATED
|
||||
table_history = f'{cls._table}__history'
|
||||
if table_history not in TABLES_CREATED:
|
||||
database.setnextid(
|
||||
transaction.connection, table_history,
|
||||
len(TABLES_CREATED) * 500 + 1)
|
||||
TABLES_CREATED.add(table_history)
|
||||
|
||||
for field_name, field in cls._fields.items():
|
||||
if field_name == 'id':
|
||||
|
||||
@@ -6,6 +6,8 @@ try:
|
||||
except ImportError:
|
||||
from importlib.metadata import entry_points
|
||||
|
||||
TABLES_CREATED = set()
|
||||
|
||||
|
||||
def register():
|
||||
from . import (
|
||||
|
||||
@@ -42,6 +42,8 @@ from trytond.transaction import Transaction, TransactionError
|
||||
from trytond.wizard import StateAction, StateView
|
||||
from trytond.wsgi import app
|
||||
|
||||
from . import TABLES_CREATED as _TABLES_CREATED
|
||||
|
||||
__all__ = [
|
||||
'CONTEXT',
|
||||
'Client',
|
||||
@@ -1339,6 +1341,7 @@ def drop_db(name=DB_NAME):
|
||||
database.drop(transaction.connection, name)
|
||||
Pool.stop(name)
|
||||
Cache.drop(name)
|
||||
_TABLES_CREATED.clear()
|
||||
|
||||
|
||||
def drop_create(name=DB_NAME, lang='en'):
|
||||
|
||||
Reference in New Issue
Block a user