Thursday, February 2, 2017
1 change · master
Enhancements to existing features
Odoo now uses structured PostgreSQL error details instead of reading information out of formatted database messages. This makes constraint violation handling more reliable, especially across localized database installations, and helps keep user-facing validation errors consistent.
Original PR description
Before 9.3, meta-information of constraint violation (e.g. column name) is partial and only available through pre-formatted error messages, which requires regex/string munging and may not contain all relevant information. In 9.3, `PQresultErrorField` was augmented with "programatic" meta-information (schema, table, column, column type and constraint names) for relevant errors, and psycopg bridged these [via a `diag` attribute on error objects](http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.Diagnostics) in 2.5. 10.0 still assumes pg9.1 support, but as soon as official DB support is 9.3 or higher this can be merged and can make error conversion simpler and more resilient. Furthermore the messages could be further improved by using `diag.table_name` to correlate models and customise error messages based on whether the error source is the current model or one of its sub-models.