fix single tag wildcard searches returning duplicate results if image has more than one match
This commit is contained in:
parent
536cba980a
commit
3b171ffc5a
@ -1038,12 +1038,14 @@ class Image {
|
|||||||
else if($positive_tag_count === 1 && $negative_tag_count === 0) {
|
else if($positive_tag_count === 1 && $negative_tag_count === 0) {
|
||||||
// MySQL is braindead, and does a full table scan on images, running the subquery once for each row -_-
|
// MySQL is braindead, and does a full table scan on images, running the subquery once for each row -_-
|
||||||
// "{$this->get_images} WHERE images.id IN (SELECT image_id FROM tags WHERE tag LIKE ?) ",
|
// "{$this->get_images} WHERE images.id IN (SELECT image_id FROM tags WHERE tag LIKE ?) ",
|
||||||
|
$group_by = ((strpos($tag_search->variables['tag0'], '%') !== FALSE) ? "GROUP BY images.id" : "");
|
||||||
$query = new Querylet("
|
$query = new Querylet("
|
||||||
SELECT images.*
|
SELECT images.*
|
||||||
FROM images
|
FROM images
|
||||||
JOIN image_tags ON images.id=image_tags.image_id
|
JOIN image_tags ON images.id=image_tags.image_id
|
||||||
JOIN tags ON image_tags.tag_id=tags.id
|
JOIN tags ON image_tags.tag_id=tags.id
|
||||||
WHERE tag LIKE :tag0
|
WHERE tag LIKE :tag0
|
||||||
|
{$group_by}
|
||||||
", $tag_search->variables);
|
", $tag_search->variables);
|
||||||
|
|
||||||
if(!empty($img_search->sql)) {
|
if(!empty($img_search->sql)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user