mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 07:10:12 +01:00
Make LIKE searches case-insensitive also on PgSQL
This commit is contained in:
parent
e89511aec8
commit
bbb9fc8809
7 changed files with 21 additions and 11 deletions
|
|
@ -766,7 +766,7 @@ class TodosController < ApplicationController
|
|||
|
||||
def get_not_completed_for_predecessor(relation, todo_id=nil)
|
||||
items = relation.todos.not_completed.
|
||||
where('(LOWER(todos.description) LIKE ?)', "%#{params[:term].downcase}%")
|
||||
where('(LOWER(todos.description) ' + Common.like_operator + '?)', "%#{params[:term].downcase}%")
|
||||
items = items.where("AND NOT(todos.id=?)", todo_id) unless todo_id.nil?
|
||||
|
||||
items.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Context < ApplicationRecord
|
|||
scope :active, -> { where state: :active }
|
||||
scope :hidden, -> { where state: :hidden }
|
||||
scope :closed, -> { where state: :closed }
|
||||
scope :with_name, lambda { |name| where("name LIKE ?", name) }
|
||||
scope :with_name, lambda { |name| where("name " + Common.like_operator + " ?", name) }
|
||||
|
||||
acts_as_list :scope => :user, :top_of_list => 0
|
||||
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ class Note < ApplicationRecord
|
|||
belongs_to :user
|
||||
belongs_to :project
|
||||
|
||||
scope :with_body, lambda { |terms| where("body LIKE ?", terms) }
|
||||
scope :with_body, lambda { |terms| where("body " + Common.like_operator + " ?", terms) }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ class Project < ApplicationRecord
|
|||
scope :completed, -> { where state: 'completed' }
|
||||
scope :uncompleted, -> { where("NOT(state = ?)", 'completed') }
|
||||
|
||||
scope :with_name_or_description, lambda { |body| where("name LIKE ? OR description LIKE ?", body, body) }
|
||||
scope :with_namepart, lambda { |body| where("name LIKE ?", body + '%') }
|
||||
scope :with_name_or_description, lambda { |body| where("name " + Common.like_operator + " ? OR description " + Common.like_operator + " ?", body, body) }
|
||||
scope :with_namepart, lambda { |body| where("name " + Common.like_operator + " ?", body + '%') }
|
||||
|
||||
before_create :set_last_reviewed_now
|
||||
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ module Search
|
|||
|
||||
def incomplete_todos(terms)
|
||||
@user.todos.
|
||||
where("(todos.description LIKE ? OR todos.notes LIKE ?) AND todos.completed_at IS NULL", terms, terms).
|
||||
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND todos.completed_at IS NULL", terms, terms).
|
||||
includes(Todo::DEFAULT_INCLUDES).
|
||||
reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))
|
||||
end
|
||||
|
||||
def complete_todos(terms)
|
||||
@user.todos.
|
||||
where("(todos.description LIKE ? OR todos.notes LIKE ?) AND NOT (todos.completed_at IS NULL)", terms, terms).
|
||||
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND NOT (todos.completed_at IS NULL)", terms, terms).
|
||||
includes(Todo::DEFAULT_INCLUDES).
|
||||
reorder("todos.completed_at DESC")
|
||||
end
|
||||
|
|
@ -46,7 +46,7 @@ module Search
|
|||
"LEFT JOIN taggings ON tags.id = taggings.tag_id "+
|
||||
"LEFT JOIN todos ON taggings.taggable_id = todos.id "+
|
||||
"WHERE todos.user_id=? "+
|
||||
"AND tags.name LIKE ? ", @user.id, terms])
|
||||
"AND tags.name " + Common.like_operator + " ? ", @user.id, terms])
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue