You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use tagged_with with multiple tags and any: true I always get 0 results and it seems to be due to a backslash getting added to all but the last tag in the SQL query.
Suppose I have tagged a post (id=1) with 'ABC'.
# The post is found as expected
Post.tagged_with(["ABC"], any: true).find(1)
=> #<Article id: 1...
In the last example the SQL query generated is adding backslashes to all but the final tag name:
SELECT "posts".* FROM "posts" WHERE EXISTS (SELECT * FROM "taggings" WHERE "taggings"."taggable_id" = "posts"."id" AND "taggings"."taggable_type" = 'Post' AND "taggings"."tag_id" IN (SELECT "tags"."id" FROM "tags" WHERE (LOWER("tags"."name") ILIKE 'abc\' ESCAPE '!' OR LOWER("tags"."name") ILIKE 'def\' ESCAPE '!' OR LOWER("tags"."name") ILIKE 'xyz' ESCAPE '!'))) AND "posts"."id" = 1 LIMIT 1;
When I copy and paste that query into the database (psql) console and run it it returns 0 rows. But when I manually remove the backslashes from the first 2 tag names and re-run the query I get the row I was originally expecting.
Is this a bug?
My setup:
ruby 2.4.0
rails 5.2.8
acts-as-taggable-on 8.1.0
The text was updated successfully, but these errors were encountered:
When I use
tagged_with
with multiple tags andany: true
I always get 0 results and it seems to be due to a backslash getting added to all but the last tag in the SQL query.Suppose I have tagged a post (id=1) with 'ABC'.
But:
In the last example the SQL query generated is adding backslashes to all but the final tag name:
When I copy and paste that query into the database (psql) console and run it it returns 0 rows. But when I manually remove the backslashes from the first 2 tag names and re-run the query I get the row I was originally expecting.
Is this a bug?
My setup:
ruby 2.4.0
rails 5.2.8
acts-as-taggable-on 8.1.0
The text was updated successfully, but these errors were encountered: