Skip to content

Soft deletes need parentheses around proceeding query? #1592

Description

@niteraven7

If $useSoftDeletes = true in the model and you perform a query that has OR in it... the returned results are not correct because the part of the query proceeding deleted=0 is not enclosed in parentheses:

SELECT * FROM user WHERE email LIKE '%kyle%' ESCAPE '!' OR first_name LIKE '%kyle%' ESCAPE '!' OR last_name LIKE '%kyle%' ESCAPE '!' AND deleted = 0

it should be like:

SELECT * FROM user WHERE (email LIKE '%kyle%' ESCAPE '!' OR first_name LIKE '%kyle%' ESCAPE '!' OR last_name LIKE '%kyle%' ESCAPE '!') AND deleted = 0

Using query builder:

$this->like('email', $keyword)->orLike('first_name', $keyword)->orLike('last_name', $keyword)->findAll();

Alpha 3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions