Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix LENGTH undefined in slug history for microsoft sqlserver. fix #330

  • Loading branch information...
commit b3594e49c2a157dca5e58d93c0e385481fb90894 1 parent 811ea88
@linuxonrails linuxonrails authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/friendly_id/history.rb
View
5 lib/friendly_id/history.rb
@@ -127,7 +127,10 @@ def conflicts
scope = Slug.where("slug = ? OR slug LIKE ?", normalized, wildcard)
scope = scope.where(:sluggable_type => sluggable_class.to_s)
scope = scope.where("sluggable_id <> ?", value) unless sluggable.new_record?
- scope.order("LENGTH(slug) DESC, slug DESC")
+
+ length_command = "LENGTH"
+ length_command = "LEN" if sluggable.connection.adapter_name =~ /sqlserver/i
+ scope.order("#{length_command}(slug) DESC, slug DESC")
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.