Tryton - Issues



Title ModelSql.create: behavior depends on database (MySQL: OperationalError/ PostgreSQL : IntegrityError)
Priority bug Status closed
Superseder Nosy List ced, pilou
Type behavior Components trytond
Assigned To Keywords

Created on 2012-10-11.23:41:28 by pilou, last changed by ced.

msg14049 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2013-09-13.23:44:42
Reported to MySQLdb:
msg11717 (view) Author: [hidden] (pilou) (Tryton committer) Date: 2012-10-12.00:11:30
review557003 : fix test_modelsql (not the code)
msg11716 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2012-10-12.00:03:17
I think it is a bug in MySQLdb or MySQL.
According to PEP 249:

            Exception raised for errors that are related to the
            database's operation and not necessarily under the control
            of the programmer, e.g. an unexpected disconnect occurs,
            the data source name is not found, a transaction could not
            be processed, a memory allocation error occurred during
            processing, etc.  It must be a subclass of DatabaseError.
            Exception raised when the relational integrity of the
            database is affected, e.g. a foreign key check fails.  It
            must be a subclass of DatabaseError.

So it is clear that it should be an IntegrityError.
Let see if they will fix it.
msg11715 (view) Author: [hidden] (pilou) (Tryton committer) Date: 2012-10-11.23:41:27
The behavior of method "ModelSql.create" [1] differs depending on the database
used (see [2] and the result [3] of the test "test_modelsql.ModelSQLTestCase" [4]).

When I try to create a new record with a missing required field,
"OperationalError" is raised with MySQL and "IntegrityError" is raised PostgreSQL.

We can choose "OperationalError" or "IntegrityError" according to value of
"CONFIG.options['db_type']", what do you think ?

By the way, there should be the same problem in "ModelSql.write" method.

[3] trytond.tests.test_modelsql.ModelSQLTestCase
Date User Action Args
2013-09-13 23:44:42cedsetstatus: deferred -> closed
messages: + msg14049
2012-10-12 00:11:31pilousetmessages: + msg11717
2012-10-12 00:03:17cedsetstatus: unread -> deferred
nosy: + ced
messages: + msg11716
2012-10-11 23:41:28piloucreate

Showing 10 items. Show all history (warning: this could be VERY long)