Files
odoo_source/odoo/addons/test_new_api
Raphael Collet 3ba3695642 [FIX] core: avoid NULLs in subselects generated for one2many fields
This fixes a problem that occurs with conditions on one2many fields,
where most conditions are translated with a subquery like

    "model".id IN (
        SELECT "comodel"."model_id" FROM "comodel" WHERE ...
    )

The issue occurs when the subquery return NULL values, i.e., when the
field "model_id" in the subquery above can be NULL.  The fix simply
consists in adding the condition "model_id IS NOT NULL" in the WHERE
clause of the subquery.

The problem with NULL values returned by subqueries is the fact that
they make the SQL condition undetermined instead of false, and this
discards some of the results returned by a query.  Simply consider:

    id NOT IN (1, 2, 3)

The value id=3 makes the condition false, while i=4 makes it true.  Now
consider that the set also includes a NULL value, like:

    id NOT IN (1, 2, 3, NULL)

The value id=3 makes the condition false, but the value id=4 makes it
undetermined.  Therefore this condition is actually undetermined for all
possible values of id, and a query containing that condition simply
returns nothing!

closes odoo/odoo#87285

X-original-commit: 6d680bac0333c6c7ce9f056cba0e1f7e9fa22f9c
Signed-off-by: Vincent Schippefilt (vsc) <vsc@odoo.com>
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-03-25 17:47:44 +01:00
..
…