summaryrefslogtreecommitdiff
path: root/odoo/tools/sql.py
diff options
context:
space:
mode:
Diffstat (limited to 'odoo/tools/sql.py')
-rw-r--r--odoo/tools/sql.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py
index 1c3fa9e98a4..3bcbd39e139 100644
--- a/odoo/tools/sql.py
+++ b/odoo/tools/sql.py
@@ -109,12 +109,10 @@ def set_not_null(cr, tablename, columnname):
query = 'ALTER TABLE "{}" ALTER COLUMN "{}" SET NOT NULL'.format(tablename, columnname)
try:
with cr.savepoint(flush=False):
- cr.execute(query)
+ cr.execute(query, log_exceptions=False)
_schema.debug("Table %r: column %r: added constraint NOT NULL", tablename, columnname)
except Exception:
- msg = "Table %r: unable to set NOT NULL on column %r!\n" \
- "If you want to have it, you should update the records and execute manually:\n%s"
- _schema.warning(msg, tablename, columnname, query, exc_info=True)
+ raise Exception("Table %r: unable to set NOT NULL on column %r", tablename, columnname)
def drop_not_null(cr, tablename, columnname):
""" Drop the NOT NULL constraint on the given column. """
@@ -138,13 +136,11 @@ def add_constraint(cr, tablename, constraintname, definition):
query2 = 'COMMENT ON CONSTRAINT "{}" ON "{}" IS %s'.format(constraintname, tablename)
try:
with cr.savepoint(flush=False):
- cr.execute(query1)
- cr.execute(query2, (definition,))
+ cr.execute(query1, log_exceptions=False)
+ cr.execute(query2, (definition,), log_exceptions=False)
_schema.debug("Table %r: added constraint %r as %s", tablename, constraintname, definition)
except Exception:
- msg = "Table %r: unable to add constraint %r!\n" \
- "If you want to have it, you should update the records and execute manually:\n%s"
- _schema.warning(msg, tablename, constraintname, query1, exc_info=True)
+ raise Exception("Table %r: unable to add constraint %r as %s", tablename, constraintname, definition)
def drop_constraint(cr, tablename, constraintname):
""" drop the given constraint. """