lib/motor/queries/persistance.rb in motor-admin-0.1.49 vs lib/motor/queries/persistance.rb in motor-admin-0.1.50
- old
+ new
@@ -14,11 +14,11 @@
query
end
def create_from_params!(params, current_user = nil)
- raise NameAlreadyExists if Query.exists?(['lower(name) = ?', params[:name].to_s.downcase])
+ raise NameAlreadyExists if Query.exists?(name: params[:name])
query = build_from_params(params, current_user)
ApplicationRecord.transaction do
query.save!
@@ -55,18 +55,18 @@
Motor::Tags.assign_tags(query, params[:tags])
end
def archive_with_existing_name(query)
- Motor::Query.where(['lower(name) = ? AND id != ?', query.name.to_s.downcase, query.id])
+ Motor::Query.where(['name = ? AND id != ?', query.name, query.id])
.update_all(deleted_at: Time.current)
end
def name_already_exists?(query)
if query.new_record?
- Query.exists?(['lower(name) = ?', query.name.to_s.downcase])
+ Query.exists?(name: query.name)
else
- Query.exists?(['lower(name) = ? AND id != ?', query.name.to_s.downcase, query.id])
+ Query.exists?(['name = ? AND id != ?', query.name, query.id])
end
end
end
end
end