V8-archive: filter bug

Created on 15 May 2019  路  3Comments  路  Source: directus/v8-archive

Bug Report

Steps to Reproduce

  1. Add Collection blog
  2. Add fileds title,description
  3. Add blog posts, title Hello world,description ' Hello Directus '
    4.Edit this post,click save as copy

image

5.delet this copy

6.filter user logical

  const getparams = {
    meta:"result_count",
    fields: "id,title,description",
    filter: {
      title:{
        logical:'or',
        contains: 'Hello'
      },
      description:{
        logical:'or',
        contains: 'Hello'
      }
    },
    status: "published"
  }

  client.getItems("blog",getparams).then((res) => {
    console.log('list',res.data)
  });

6.The deleted data can also be queried because there is this item in the database.

Expected Behavior

Actual Behavior

Other Context & Screenshots

Technical Details

  • Device: [eg: Desktop]
  • OS: [eg: MacOS 10.13.6]
  • Web Server: [eg: Nginx 1.8]
  • PHP Version: [eg: 7.3]
  • Database: [eg: MySQL 5.7]
  • Install Method: [eg: cloned master branch]
bug

Most helpful comment

This issue will replicate if you have status field in your collection. And issue occurs cause of MySQL where condition priority. For your filters; query have the condition like

WHERE title LIKE '%Hello%' OR title_des LIKE '%Hello%' AND status IN ('published', 'draft')

But it should like

WHERE (title LIKE '%Hello%' OR title_des LIKE '%Hello%') AND status IN ('published', 'draft')

I found the problem. Will send the PR ASAP.

All 3 comments

Hey @cdwmhcc ,

I am not able to reproduce this issue as when I deleted the duplicate entry, it was deleted from DB too. So I got the single entry only instead of both of them.

This issue will replicate if you have status field in your collection. And issue occurs cause of MySQL where condition priority. For your filters; query have the condition like

WHERE title LIKE '%Hello%' OR title_des LIKE '%Hello%' AND status IN ('published', 'draft')

But it should like

WHERE (title LIKE '%Hello%' OR title_des LIKE '%Hello%') AND status IN ('published', 'draft')

I found the problem. Will send the PR ASAP.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nitwel picture Nitwel  路  3Comments

maettyhawk picture maettyhawk  路  3Comments

cdwmhcc picture cdwmhcc  路  3Comments

metalmarco picture metalmarco  路  3Comments

gitlabisbetterthangithub picture gitlabisbetterthangithub  路  3Comments