Tryton - Issues

 

Issue8080

Title TypeError: unorderable types: datetime.datetime() > str()
Priority bug Status resolved
Superseder Nosy List ced, dave, nicoe, reviewbot, roundup-bot
Type crash Components trytond
Assigned To ced Keywords review, sqlite
Reviews 54521002,48721002
View: 54521002, 48721002

Created on 2019-02-06.12:42:24 by dave, last changed by roundup-bot.

Messages
New changeset 3d43b7fa6331 by Cédric Krier in branch 'default':
Cast timestamp as datetime for sqlite back-end
https://hg.tryton.org/tryton-env/rev/3d43b7fa6331
New changeset 4ae2d4ab6704 by Cédric Krier in branch 'default':
Cast timestamp as datetime for sqlite back-end
https://hg.tryton.org/trytond/rev/4ae2d4ab6704
msg46800 (view) Author: [hidden] (dave) Date: 2019-02-06.19:35:24
Both of the reviews (review48721002 or review54521002) fix the problem, thanks.

For the record, I was running the tests on a Debian Stable machine, so the version of SQLite is probably quite old now:
$ python3 -c "import sqlite3; print(sqlite3.sqlite_version);"
3.16.2
review48721002 updated at https://codereview.tryton.org/48721002/#ps1
msg46788 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-02-06.17:26:57
Indeed the problem is probably there since the first implementation of Cache. But it was never triggered because nobody run in production with SQLite. The changeset a83631f4ba67 makes this problem raises more often.
Here is review48721002 which ensure to cast the timestamp and add a test for the sync code.
review54521002 updated at https://codereview.tryton.org/54521002/#ps1
msg46778 (view) Author: [hidden] (nicoe) (Tryton committer) Date: 2019-02-06.16:26:40
I couldn't reproduce it that way either but while using sqlite I had the same traceback.

This is related to trytond changeset a83631f4ba67 and specifically to the query computing the timestamp in Cache.commit.

nicoe@mirabelle:~/training/tryton-env/training% sqlite3 --version
3.26.0 2018-12-12 11:57:35 bc891ac6b62fe7d9a5c157a95d0b9dc2559f7abb84d7b22e258acb9b250calt1
msg46774 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-02-06.13:19:15
I can not reproduce. Maybe it is linked to the SQLite version?
msg46768 (view) Author: [hidden] (dave) Date: 2019-02-06.12:42:23
When running particular sets of module tests togethor using run-test.py the tests fail with "TypeError: unorderable types: datetime.datetime() > str()".

This always seems to happen here: http://hg.tryton.org/trytond/file/tip/trytond/cache.py#l134
both timestamp and inst_timestamp appear to be the same timestamp, but of different types:
    timestamp: datetime.datetime(2019, 2, 6, 11, 38, 50, 673473)
    inst_timestamp: '2019-02-06 11:38:50.673473'


Here are two examples using different sets of modules:

$ ./trytond/trytond/tests/run-tests.py -f -v -m account_statement account_statement_aeb43 account_statement_coda account_statement_ofx stock_package_shipping_dpd stock_package_shipping_ups
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:309: UserWarning: Unable to remove not null with SQLite backend
  warnings.warn('Unable to remove not null with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:244: UserWarning: Unable to drop foreign key with SQLite backend
  warnings.warn('Unable to drop foreign key with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:314: UserWarning: Unable to add constraint with SQLite backend
  warnings.warn('Unable to add constraint with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:307: UserWarning: Unable to set not null with SQLite backend
  warnings.warn('Unable to set not null with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:175: UserWarning: Unable to set default on column with SQLite backend
  warnings.warn('Unable to set default on column with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:241: UserWarning: Unable to add foreign key with SQLite backend
  warnings.warn('Unable to add foreign key with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:317: UserWarning: Unable to drop constraint with SQLite backend
  warnings.warn('Unable to drop constraint with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:283: UserWarning: Unable to create index with parameters
  warnings.warn('Unable to create index with parameters')
................................................................F
======================================================================
FAIL: /home/tryton/tryton-env/trytond/trytond/modules/account_statement_ofx/tests/scenario_account_statement_ofx.rst
Doctest: scenario_account_statement_ofx.rst
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.5/doctest.py", line 2190, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for scenario_account_statement_ofx.rst
  File "/home/tryton/tryton-env/trytond/trytond/modules/account_statement_ofx/tests/scenario_account_statement_ofx.rst", line 0

----------------------------------------------------------------------
File "/home/tryton/tryton-env/trytond/trytond/modules/account_statement_ofx/tests/scenario_account_statement_ofx.rst", line 18, in scenario_account_statement_ofx.rst
Failed example:
    config = activate_modules('account_statement_ofx')
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.5/doctest.py", line 1321, in __run
        compileflags, 1), test.globs)
      File "<doctest scenario_account_statement_ofx.rst[6]>", line 1, in <module>
        config = activate_modules('account_statement_ofx')
      File "/home/tryton/tryton-env/trytond/trytond/tests/tools.py", line 25, in activate_modules
        Wizard('ir.module.activate_upgrade').execute('upgrade')
      File "/home/tryton/tryton-env/proteus/proteus/__init__.py", line 1175, in execute
        view['fields_view']['model'], self._config)()
      File "/home/tryton/tryton-env/proteus/proteus/__init__.py", line 727, in get
        class Spam(Model, metaclass=MetaModelFactory(name, config=config)()):
      File "/home/tryton/tryton-env/proteus/proteus/__init__.py", line 458, in __new__
        dict['_fields'] = proxy.fields_get(None, context)
      File "/home/tryton/tryton-env/proteus/proteus/config.py", line 175, in __call__
        self._config.user, readonly=rpc.readonly) as transaction:
      File "/home/tryton/tryton-env/trytond/trytond/transaction.py", line 111, in start
        Cache.sync(self)
      File "/home/tryton/tryton-env/trytond/trytond/cache.py", line 134, in sync
        if not inst_timestamp or timestamp > inst_timestamp:
    TypeError: unorderable types: datetime.datetime() > str()


----------------------------------------------------------------------
Ran 65 tests in 301.670s

FAILED (failures=1)




$ ./trytond/trytond/tests/run-tests.py -f -v -m product product_attribute product_cost_fifo stock stock_lot stock_split
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:309: UserWarning: Unable to remove not null with SQLite backend
  warnings.warn('Unable to remove not null with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:244: UserWarning: Unable to drop foreign key with SQLite backend
  warnings.warn('Unable to drop foreign key with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:314: UserWarning: Unable to add constraint with SQLite backend
  warnings.warn('Unable to add constraint with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:307: UserWarning: Unable to set not null with SQLite backend
  warnings.warn('Unable to set not null with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:175: UserWarning: Unable to set default on column with SQLite backend
  warnings.warn('Unable to set default on column with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:241: UserWarning: Unable to add foreign key with SQLite backend
  warnings.warn('Unable to add foreign key with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:317: UserWarning: Unable to drop constraint with SQLite backend
  warnings.warn('Unable to drop constraint with SQLite backend')
/home/tryton/tryton-env/trytond/trytond/backend/sqlite/table.py:283: UserWarning: Unable to create index with parameters
  warnings.warn('Unable to create index with parameters')
................................................................................F
======================================================================
FAIL: /home/tryton/tryton-env/trytond/trytond/modules/stock/tests/scenario_stock_shipment_out_return_same_storage_input.rst
Doctest: scenario_stock_shipment_out_return_same_storage_input.rst
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.5/doctest.py", line 2190, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for scenario_stock_shipment_out_return_same_storage_input.rst
  File "/home/tryton/tryton-env/trytond/trytond/modules/stock/tests/scenario_stock_shipment_out_return_same_storage_input.rst", line 0

----------------------------------------------------------------------
File "/home/tryton/tryton-env/trytond/trytond/modules/stock/tests/scenario_stock_shipment_out_return_same_storage_input.rst", line 15, in scenario_stock_shipment_out_return_same_storage_input.rst
Failed example:
    config = activate_modules('stock')
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.5/doctest.py", line 1321, in __run
        compileflags, 1), test.globs)
      File "<doctest scenario_stock_shipment_out_return_same_storage_input.rst[4]>", line 1, in <module>
        config = activate_modules('stock')
      File "/home/tryton/tryton-env/trytond/trytond/tests/tools.py", line 18, in activate_modules
        cfg = _get_config()
      File "/home/tryton/tryton-env/trytond/trytond/tests/tools.py", line 32, in _get_config
        cfg = pconfig.set_trytond()
      File "/home/tryton/tryton-env/proteus/proteus/config.py", line 286, in set_trytond
        _CONFIG.current = TrytondConfig(database, user, config_file=config_file)
      File "/home/tryton/tryton-env/proteus/proteus/config.py", line 241, in __init__
        with Transaction().start(self.database_name, 0) as transaction:
      File "/home/tryton/tryton-env/trytond/trytond/transaction.py", line 111, in start
        Cache.sync(self)
      File "/home/tryton/tryton-env/trytond/trytond/cache.py", line 134, in sync
        if not inst_timestamp or timestamp > inst_timestamp:
    TypeError: unorderable types: datetime.datetime() > str()


----------------------------------------------------------------------
Ran 81 tests in 298.256s

FAILED (failures=1)
History
Date User Action Args
2019-02-13 10:24:01roundup-botsetmessages: + msg46972
2019-02-13 10:23:56roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg46971
2019-02-06 19:35:25davesetmessages: + msg46800
2019-02-06 17:37:25reviewbotsetmessages: + msg46791
2019-02-06 17:35:21cedsetkeyword: + sqlite
2019-02-06 17:27:03cedsettype: behavior -> crash
2019-02-06 17:26:58cedsetstatus: need-eg -> testing
reviews: 54521002 -> 54521002,48721002
messages: + msg46788
assignedto: ced
2019-02-06 16:40:51reviewbotsetnosy: + reviewbot
messages: + msg46780
2019-02-06 16:26:40nicoesetreviews: 54521002
nosy: + nicoe
messages: + msg46778
keyword: + review
2019-02-06 13:19:15cedsetstatus: unread -> need-eg
nosy: + ced
messages: + msg46774
2019-02-06 12:42:24davecreate