-
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
Possible fix for issue #409 #416
Changes from 4 commits
15a2a01
1d2082f
0455d4b
7be5492
826a228
f3d7538
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,14 @@ def using_sqlite? | |
::ActiveRecord::Base.connection && ::ActiveRecord::Base.connection.adapter_name == 'SQLite' | ||
end | ||
|
||
def using_mysql? | ||
::ActiveRecord::Base.connection && ::ActiveRecord::Base.connection.adapter_name.downcase =~ /mysql/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change this to make a db connection, when before it just checked the configured adapter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it to be consistent with |
||
end | ||
|
||
def sha_prefix(string) | ||
Digest::SHA1.hexdigest("#{string}#{rand}")[0..6] | ||
end | ||
|
||
private | ||
def like_operator | ||
using_postgresql? ? 'ILIKE' : 'LIKE' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to replace Tag.named_any entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was not the intent. The intent was to push the tag comparison to the database because of collation problems. Tag.named_any works great to retrieve the requested tags.
The problem was comparing the tag strings with strings in ruby. In my case I am using MySQL with utf8_general_ci collation. I had the a tag with the string 'inupiat' and tried to add a tag with the string 'IÑUPIAT'. Tag.named_any('IÑUPIAT') does find the tag with string 'inupiat', but when we compare with comparable_name they are not the same, so an attempt to create a new tag is made. I also have a unique index on tag name, so this threw an error. Since I could not make the comparable_name compare the tags the same way, I pushed that to the database. Sorry for the long winded response. Does that make sense?