Skip to content

Commit d14c8e2

Browse files
committed
Revert slug query to plain equality in identifier_not_historically_reserved
LOWER(slug) = LOWER(?) is unnecessary because normalizes :identifier ensures consistent casing before FriendlyId records the slug. Plain equality uses the existing composite index on (slug, sluggable_type).
1 parent 3da6593 commit d14c8e2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/models/projects/identifier.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ def identifier_not_reserved
147147
end
148148

149149
# Checks friendly_id_slugs for any project that previously used this identifier and
150-
# has since changed it. It allows to switch back to an identifier the project itself
151-
# has used before. Uses case-insensitive comparison to prevent cross-case collisions.
150+
# has since changed it. It allows a project to switch back to an identifier it has
151+
# used before. Plain equality works because `normalizes :identifier` ensures consistent
152+
# casing before FriendlyId records the slug.
152153
def identifier_not_historically_reserved
153154
return if errors.any? { |error| error.attribute == :identifier && error.type == :taken }
154155

155156
already_existing = FriendlyId::Slug
156-
.where("LOWER(slug) = LOWER(?)", identifier)
157-
.where(sluggable_type: self.class.to_s)
157+
.where(slug: identifier, sluggable_type: self.class.to_s)
158158
.where.not(sluggable_id: id)
159159
.exists?
160160

0 commit comments

Comments
 (0)