Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'AND' queries between multiple columns is not working #100

Open
matthewhegarty opened this issue Feb 12, 2021 · 3 comments
Open

'AND' queries between multiple columns is not working #100

matthewhegarty opened this issue Feb 12, 2021 · 3 comments

Comments

@matthewhegarty
Copy link
Collaborator

matthewhegarty commented Feb 12, 2021

Whilst submitting the answer to #97 I noticed that the AND behaviour is not supported.

The docs say:

The values within a single name field are tied together using a logical OR operator for filtering, while those between name fields are strung together with an AND operator. This means that Datatables’ multicolumn search functionality is preserved.

(e.g. for albums_by_decade)

        "columns": [
            {"data": "rank", "searchable": false},
            {"data": "artist.name", "name": "artist.name, year"},
            {"data": "name"},
            {"data": "year"},
            {"data": "genres", "name": "genres.name", "sortable": false},
        ]

However, if you examine the SQL produced by the example app there is no AND query produced:

SELECT DISTINCT "albums_album"."id",
                "albums_album"."name",
                "albums_album"."rank",
                "albums_album"."year",
                "albums_album"."artist_id"
FROM "albums_album"
         INNER JOIN "albums_artist" ON ("albums_album"."artist_id" = "albums_artist"."id")
         LEFT OUTER JOIN "albums_album_genres" ON ("albums_album"."id" = "albums_album_genres"."album_id")
         LEFT OUTER JOIN "albums_genre" ON ("albums_album_genres"."genre_id" = "albums_genre"."id")
WHERE ("albums_artist"."name" LIKE '%19%' ESCAPE '\' OR "albums_album"."year" LIKE '%19%' ESCAPE '\' OR
 "albums_album"."name" LIKE
 '%19%' ESCAPE '\' OR
   "albums_album"."year" LIKE
   '%19%' ESCAPE
   '\' OR "albums_genre"."name" LIKE '%19%' ESCAPE '\')
ORDER BY "albums_album"."rank" ASC
LIMIT 10;

Is this a bug or have I misunderstood how this works?

@izimobil
Copy link
Owner

I have to check that, I can't remember the expected behavior.

@AustinGilkison
Copy link

Also having issues with AND query functionality.

@izimobil
Copy link
Owner

OK. Care to elaborate ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants