David Feshbach created CAY-1903:
-----------------------------------

             Summary: In-memory matching using Expressions with nulls
                 Key: CAY-1903
                 URL: https://issues.apache.org/jira/browse/CAY-1903
             Project: Cayenne
          Issue Type: Bug
          Components: Core Library
    Affects Versions: 3.2.M2
            Reporter: David Feshbach


When a NULL is encountered in a WHERE clause in SQL, it stays NULL (not true or 
false) unless it is part of an IS NULL, IS NOT NULL, AND (false), or OR (true). 
If the entire expression is NULL, the row is not matched.

Cayenne Expressions behave differently in memory. Additionally there is a 
breaking change in CAY-1860. Expressions that used to work, (and matched 
database behavior,) now throw an exception. For example:

Expression expr = Artist.DATE_OF_DEATH.gt(new Date(0));

This expression used to match all artists that died after 1970 and exclude all 
living artists. Now it throws an exception if it tries to match a living artist.

before CAY-1860:
(null) > 0              -> false
NOT ((null) > 0)   -> true
0 > (null)              -> false
0 < (null)              -> false

after CAY-1860:
(null) > 0              -> ExpressionException
NOT ((null) > 0)   -> ExpressionException
0 > (null)              -> true
0 < (null)              -> false

In SQL:
(null) > 0              -> null (no match)
NOT ((null) > 0)   -> null
0 > (null)              -> null
0 < (null)              -> null
NOT (null)            -> null
(null) AND (true)  -> null
(null) OR (false)   -> null
(null) OR (true)    -> true
(null) AND (false) -> false




--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to