Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #330 from btrepp/master

Fix LENGTH undefined in microsoft sqlserver
  • Loading branch information...
commit 5b8be2c736a10e676a57e750d07b37a018a5a5ed 2 parents b07a13c + 707096d
@parndt parndt authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/friendly_id/slug_generator.rb
View
5 lib/friendly_id/slug_generator.rb
@@ -59,7 +59,10 @@ def conflicts
base << "ESCAPE '\\'" if sluggable.connection.adapter_name =~ /sqlite/i
scope = sluggable_class.unscoped.where(base, normalized, wildcard)
scope = scope.where("#{pkey} <> ?", value) unless sluggable.new_record?
- scope = scope.order("LENGTH(#{column}) DESC, #{column} DESC")
+
+ length_command = "LENGTH"
+ length_command = "LEN" if sluggable.connection.adapter_name =~ /sqlserver/i
+ scope = scope.order("#{length_command}(#{column}) DESC, #{column} DESC")
end
def friendly_id_config
Please sign in to comment.
Something went wrong with that request. Please try again.