Permalink
Browse files

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

  • Loading branch information...
1 parent 811ea88 commit b3594e49c2a157dca5e58d93c0e385481fb90894 @linuxonrails linuxonrails committed Dec 13, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 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

0 comments on commit b3594e4

Please sign in to comment.