Skip to content

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

@matthewhegarty

Description

@matthewhegarty

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions