Feature #35073 » 35073-sqlite-fix.patch
app/models/principal.rb | ||
---|---|---|
72 | 72 |
where({}) |
73 | 73 |
else |
74 | 74 |
pattern = "%#{sanitize_sql_like q}%" |
75 |
sql = +"LOWER(#{table_name}.login) LIKE LOWER(:p)" |
|
76 |
sql << " OR #{table_name}.id IN (SELECT user_id FROM #{EmailAddress.table_name} WHERE LOWER(address) LIKE LOWER(:p))" |
|
77 |
params = {:p => pattern} |
|
75 |
sql = +"LOWER(#{table_name}.login) LIKE LOWER(:p) ESCAPE :s"
|
|
76 |
sql << " OR #{table_name}.id IN (SELECT user_id FROM #{EmailAddress.table_name} WHERE LOWER(address) LIKE LOWER(:p) ESCAPE :s)"
|
|
77 |
params = {:p => pattern, :s => '\\'}
|
|
78 | 78 | |
79 | 79 |
tokens = q.split(/\s+/).reject(&:blank?).map {|token| "%#{sanitize_sql_like token}%"} |
80 | 80 |
if tokens.present? |
81 | 81 |
sql << ' OR (' |
82 | 82 |
sql << tokens.map.with_index do |token, index| |
83 | 83 |
params[:"token_#{index}"] = token |
84 |
"(LOWER(#{table_name}.firstname) LIKE LOWER(:token_#{index}) OR LOWER(#{table_name}.lastname) LIKE LOWER(:token_#{index}))"
|
|
84 |
"(LOWER(#{table_name}.firstname) LIKE LOWER(:token_#{index}) ESCAPE :s OR LOWER(#{table_name}.lastname) LIKE LOWER(:token_#{index}) ESCAPE :s)"
|
|
85 | 85 |
end.join(' AND ') |
86 | 86 |
sql << ')' |
87 | 87 |
end |
app/models/project.rb | ||
---|---|---|
108 | 108 |
scope :like, (lambda do |arg| |
109 | 109 |
if arg.present? |
110 | 110 |
pattern = "%#{sanitize_sql_like arg.to_s.strip}%" |
111 |
where("LOWER(identifier) LIKE LOWER(:p) OR LOWER(name) LIKE LOWER(:p)", :p => pattern)
|
|
111 |
where("LOWER(identifier) LIKE LOWER(:p) ESCAPE :s OR LOWER(name) LIKE LOWER(:p) ESCAPE :s", :p => pattern, :s => '\\')
|
|
112 | 112 |
end |
113 | 113 |
end) |
114 | 114 |
scope :sorted, lambda {order(:lft)} |
lib/redmine/database.rb | ||
---|---|---|
71 | 71 |
else |
72 | 72 |
"#{left} #{neg}ILIKE #{right}" |
73 | 73 |
end |
74 |
elsif sqlite? |
|
75 |
"#{left} #{neg}LIKE #{right} ESCAPE '\\'" |
|
74 | 76 |
else |
75 | 77 |
"#{left} #{neg}LIKE #{right}" |
76 | 78 |
end |