[FIX] registry: misuse of psycopg2.sql import

Part-of: odoo/odoo#134677
This commit is contained in:
Raphael Collet
2023-09-27 03:01:44 +00:00
parent 020ddc3a6b
commit 353fbb33ef
+6 -4
View File
@@ -26,7 +26,7 @@ from .. import SUPERUSER_ID
from odoo.sql_db import TestCursor
from odoo.tools import (
config, existing_tables, lazy_classproperty,
lazy_property, sql, Collector, OrderedSet,
lazy_property, sql, Collector, OrderedSet, SQL,
format_frame
)
from odoo.tools.func import locked
@@ -797,9 +797,11 @@ class Registry(Mapping):
for sequence_name in sequence_names:
if sequence_name not in existing_sequences:
_sequence_name = sql.Identifier(sequence_name) # even if sequence_name should be safe, will avoid flagging the sql_injection linter
cr.execute(sql.SQL("CREATE SEQUENCE {} INCREMENT BY 1 START WITH 1").format(_sequence_name))
cr.execute("SELECT nextval(%s)", [sequence_name])
cr.execute(SQL(
"CREATE SEQUENCE %s INCREMENT BY 1 START WITH 1",
SQL.identifier(sequence_name),
))
cr.execute(SQL("SELECT nextval(%s)", sequence_name))
db_registry_sequence, db_cache_sequences = self.get_sequences(cr)
self.registry_sequence = db_registry_sequence