-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
tagged_with searches and inconsistent case sensitivity #869
Comments
tekniklr
added a commit
to tekniklr/acts-as-taggable-on
that referenced
this issue
Nov 15, 2017
Fodoj
pushed a commit
to Fodoj/acts-as-taggable-on
that referenced
this issue
Jun 4, 2018
Fodoj
pushed a commit
to Fodoj/acts-as-taggable-on
that referenced
this issue
Jun 5, 2018
…sses mbleigh#869" This reverts commit ac585c8.
Fodoj
pushed a commit
to Fodoj/acts-as-taggable-on
that referenced
this issue
Jun 5, 2018
…e; addresses mbleigh#869"" This reverts commit bc7ec0d.
This was referenced Mar 12, 2021
tekniklr
added a commit
to tekniklr/acts-as-taggable-on
that referenced
this issue
Mar 19, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When searching using
Model.tagged_with('Tagname')
, nothing is returned, despite these taggings existing. Comparing the SQL generated withModel.tagged_with('Tagname', any: true)
revealed why- the latter forces lower case in SQL, the former does not. Since the actual tag name is capitalized in the database, it can never be returned in search without searching forany
.without
any: true
(incorrectly case sensitive):SELECT "NOTES".* FROM "NOTES" INNER JOIN "TAGGINGS" "NOTE_TAGGINGS_8D57F90" ON "NOTE_TAGGINGS_8D57F90"."TAGGABLE_ID" = "NOTES"."ID" AND "NOTE_TAGGINGS_8D57F90"."TAGGABLE_TYPE" = 'Note' AND "NOTE_TAGGINGS_8D57F90"."TAG_ID" IN (SELECT "TAGS"."ID" FROM "TAGS" WHERE "TAGS"."NAME" LIKE 'concerns' ESCAPE '!')
with
any: true
(no case sensitivity- everything is lowercased in SQL):SELECT "NOTES".* FROM "NOTES" WHERE (EXISTS (SELECT * FROM "TAGGINGS" WHERE "TAGGINGS"."TAGGABLE_ID" = "NOTES"."ID" AND "TAGGINGS"."TAGGABLE_TYPE" = 'Note' AND "TAGGINGS"."TAG_ID" IN (SELECT "TAGS"."ID" FROM "TAGS" WHERE (LOWER("TAGS"."NAME") LIKE 'concerns' ESCAPE '!'))))
Running the first query in a SQL console and changing
SELECT "TAGS"."ID" FROM "TAGS" WHERE "TAGS"."NAME" LIKE 'concerns' ESCAPE '!'
toSELECT "TAGS"."ID" FROM "TAGS" WHERE (LOWER("TAGS"."NAME") LIKE 'concerns' ESCAPE '!'
works as expected.The text was updated successfully, but these errors were encountered: