moodle/user/classes
Andrew Nicols 8bcf74e9bc MDL-69026 user: Wrap sub-query in brackets
It is perfectly valid to have a query like:

Match None of the following:
- Role is ANY of the following:
-- 'Teacher'
-- 'Editing teacher'
-- 'Manager'; AND
- Keyword is NONE of the following:
-- 'Kevin'

However, due to the way in which the query is constructed, this leads to
a query which includes

    WHERE NOT ef.id IS NOT NULL
    AND NOT
        u.id IN (SELECT userid FROM {role_assignments} WHERE roleid IN (...) AND contextid IN (...))
    AND NOT
        NOT (u.firstname || ' ' || u.lastname LIKE '%Kevin%')

The use of NOT NOT is valid in Postgres, MariaDB, MySQL, and MSSQL, but
not in Oracle.

To counter this when the outer jointype is of type NONE, we must wrap
each of the inner WHERE clauses in a set of brackets, which makes the
query:

    WHERE NOT ef.id IS NOT NULL
    AND NOT
        (u.id IN (SELECT userid FROM {role_assignments} WHERE roleid IN (...) AND contextid IN (...)))
    AND NOT
        (NOT (u.firstname || ' ' || u.lastname LIKE '%Kevin%'))

Whilst Oracle does not support the use of `AND NOT NOT ...`, it does support
`AND NOT (NOT ...)`
2020-06-12 10:03:06 +08:00
..
analytics MDL-62191 analytics: Support for bulk actions 2019-09-27 14:13:52 +08:00
external MDL-57273 core: Exporters support custom formatting parameters 2017-01-20 12:56:19 +08:00
form MDL-57208 user: select default homepage from user preferences page. 2019-07-30 08:53:18 +01:00
output MDL-68612 user: Participants filter row accessibility improvements 2020-05-29 12:18:39 +08:00
privacy MDL-67883 core: Make core ready for MoodleNet. 2020-06-05 11:47:42 +08:00
search MDL-60913 search: add search area categories 2019-01-23 10:28:43 +11:00
table MDL-69026 user: Wrap sub-query in brackets 2020-06-12 10:03:06 +08:00
course_form.php MDL-53399 core: "activity chooser off/on" in user preference 2016-06-03 00:46:16 -06:00