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

tagged_with searches and inconsistent case sensitivity #869

Closed
tekniklr opened this issue Nov 11, 2017 · 0 comments
Closed

tagged_with searches and inconsistent case sensitivity #869

tekniklr opened this issue Nov 11, 2017 · 0 comments

Comments

@tekniklr
Copy link
Contributor

  • acts-as-taggable-on (5.0.0)
  • rails (5.1.4)
  • activerecord-oracle_enhanced-adapter (1.8.2)
  • ruby 2.4.2

When searching using Model.tagged_with('Tagname'), nothing is returned, despite these taggings existing. Comparing the SQL generated with Model.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 for any.

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 '!' to SELECT "TAGS"."ID" FROM "TAGS" WHERE (LOWER("TAGS"."NAME") LIKE 'concerns' ESCAPE '!' works as expected.

tekniklr added a commit to tekniklr/acts-as-taggable-on that referenced this issue Nov 15, 2017
@seuros seuros closed this as completed Jun 1, 2018
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
Fodoj pushed a commit to Fodoj/acts-as-taggable-on that referenced this issue Jun 5, 2018
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants