Skip to content
  • Guilhem Bichot's avatar
    78025d0f
    Bug#31168181 FILTERING USING JSON FIELD, IS TRUE DOES NOT WORK · 78025d0f
    Guilhem Bichot authored
    
    
    Users get confused when testing a JSON literal true/false in boolean
    context like
    a) NOT(JSON value containing literal)
    b) WHERE JSON value containing literal
    c) JSON value containing literal IS TRUE/FALSE.
    And it's a bit of our fault, as this used to work in 5.7.
    But it stopped working in 8.0 after
    WL#12358: Ensure that all predicates in SQL conditions are complete
    and
    WL#4245 Convert NOT IN and NOT EXISTS in WHERE/ON to an antijoin
    (both introduced in 8.0.17).
    We cannot easily restore the behaviour of 5.7, and it's questionable
    if we should. The SQL standard doesn't ask that JSON values be
    implicitly cast to SQL values when needed, it rather expects the user
    to use JSON_VALUE for that.
    
    To help users a bit we start emitting a warning if they have
    constructs like above, and a suggestion (using JSON_VALUE).
    
    Note that we already did this for e.g. BETWEEN:
    +--------------------------------------+
    | cast(false as json) between -1 and 3 |
    +--------------------------------------+
    |                                    1 |
    +--------------------------------------+
    Warning (Code 1235): This version of MySQL doesn't yet support 'comparison of JSON in the BETWEEN operator'
    
    We do not do the same for IS NULL (which has problems too, see Bug #
    25822217), because there are cases where JSON functions do return SQL
    NULL, so we cannot warn each time a JSON function is an argument of IS
    NULL, it may be a valid test. Even though some JSON functions don't
    return SQL NULL when operating on a JSON literal null (and, that's
    when some users think they should... see bug 85755).
    
    Reviewed-by: default avatarCatalin Besleaga <catalin.besleaga@oracle.com>
    Change-Id: I4ce5d06b4d6c40a4ce68220375a4505d349df235
    78025d0f
    Bug#31168181 FILTERING USING JSON FIELD, IS TRUE DOES NOT WORK
    Guilhem Bichot authored
    
    
    Users get confused when testing a JSON literal true/false in boolean
    context like
    a) NOT(JSON value containing literal)
    b) WHERE JSON value containing literal
    c) JSON value containing literal IS TRUE/FALSE.
    And it's a bit of our fault, as this used to work in 5.7.
    But it stopped working in 8.0 after
    WL#12358: Ensure that all predicates in SQL conditions are complete
    and
    WL#4245 Convert NOT IN and NOT EXISTS in WHERE/ON to an antijoin
    (both introduced in 8.0.17).
    We cannot easily restore the behaviour of 5.7, and it's questionable
    if we should. The SQL standard doesn't ask that JSON values be
    implicitly cast to SQL values when needed, it rather expects the user
    to use JSON_VALUE for that.
    
    To help users a bit we start emitting a warning if they have
    constructs like above, and a suggestion (using JSON_VALUE).
    
    Note that we already did this for e.g. BETWEEN:
    +--------------------------------------+
    | cast(false as json) between -1 and 3 |
    +--------------------------------------+
    |                                    1 |
    +--------------------------------------+
    Warning (Code 1235): This version of MySQL doesn't yet support 'comparison of JSON in the BETWEEN operator'
    
    We do not do the same for IS NULL (which has problems too, see Bug #
    25822217), because there are cases where JSON functions do return SQL
    NULL, so we cannot warn each time a JSON function is an argument of IS
    NULL, it may be a valid test. Even though some JSON functions don't
    return SQL NULL when operating on a JSON literal null (and, that's
    when some users think they should... see bug 85755).
    
    Reviewed-by: default avatarCatalin Besleaga <catalin.besleaga@oracle.com>
    Change-Id: I4ce5d06b4d6c40a4ce68220375a4505d349df235
Loading