Python3 cross-type comparison breaks sql query
Migrating stock_lot_sled has failed test [1] in Python3. The error "unorderable types str() > NoneType()" results from the following call:
self.cursor.execute(sql, params)
where sql is:
'SELECT "b"."id" FROM "stock_move" AS "a" INNER JOIN "stock_lot" AS "b" ON ("a"."lot" = "b"."id") WHERE ((GREATEST("a"."effective_date", "a"."planned_date") <= ?) AND ("b"."shelf_life_expiration_date" >= ?))'
and params is:
(datetime.date(2016, 2, 19), datetime.date(2016, 2, 29))
This seems to be the result of the fact that, in None can be compared to str in Python2, but not in Python3.
Eg: python2 >>> None < 'foo' # True;
python3 >>> None < 'foo' # unorderable types: NoneType() < str()
In the stock_lot_sled case, planned_date and shelf_life_expiration_date are not always required.
[1] stock_lot_sled/tests/test_stock_lot_sled.py line 76