Feature #24013 » issue-24013-r16009-keywords.diff
app/helpers/my_helper.rb | ||
---|---|---|
82 | 82 |
limit(10). |
83 | 83 |
includes(:status, :project, :tracker, :priority). |
84 | 84 |
references(:status, :project, :tracker, :priority). |
85 |
order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC")
|
|
85 |
order("#{IssuePriority.table_name}.#{'position'.quote_column_name} DESC, #{Issue.table_name}.updated_on DESC")
|
|
86 | 86 |
end |
87 | 87 | |
88 | 88 |
def issuesreportedbyme_items |
... | ... | |
117 | 117 |
joins(:activity, :project). |
118 | 118 |
references(:issue => [:tracker, :status]). |
119 | 119 |
includes(:issue => [:tracker, :status]). |
120 |
order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC").
|
|
120 |
order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.#{'position'.quote_column_name} ASC, #{Issue.table_name}.id ASC").
|
|
121 | 121 |
to_a |
122 | 122 | |
123 | 123 |
return entries, days |
app/models/enumeration.rb | ||
---|---|---|
150 | 150 |
super |
151 | 151 |
if position_changed? |
152 | 152 |
self.class.where.not(:parent_id => nil).update_all( |
153 |
"position = coalesce((
|
|
154 |
select position
|
|
155 |
from (select id, position from enumerations) as parent
|
|
153 |
"#{'position'.quote_column_name} = coalesce((
|
|
154 |
select #{'position'.quote_column_name}
|
|
155 |
from (select id, #{'position'.quote_column_name} from enumerations) as parent
|
|
156 | 156 |
where parent_id = parent.id), 1)" |
157 | 157 |
) |
158 | 158 |
end |
app/models/issue.rb | ||
---|---|---|
1548 | 1548 |
if p.priority_derived? |
1549 | 1549 |
# priority = highest priority of open children |
1550 | 1550 |
# priority is left unchanged if all children are closed and there's no default priority defined |
1551 |
if priority_position = p.children.open.joins(:priority).maximum("#{IssuePriority.table_name}.position")
|
|
1551 |
if priority_position = p.children.open.joins(:priority).maximum("#{IssuePriority.table_name.quote_table_name}.#{'position'.quote_column_name}")
|
|
1552 | 1552 |
p.priority = IssuePriority.find_by_position(priority_position) |
1553 | 1553 |
elsif default_priority = IssuePriority.default |
1554 | 1554 |
p.priority = default_priority |
app/models/issue_query.rb | ||
---|---|---|
23 | 23 |
self.available_columns = [ |
24 | 24 |
QueryColumn.new(:id, :sortable => "#{Issue.table_name}.id", :default_order => 'desc', :caption => '#', :frozen => true), |
25 | 25 |
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true), |
26 |
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position", :groupable => true),
|
|
26 |
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.#{'position'.quote_column_name}", :groupable => true),
|
|
27 | 27 |
QueryColumn.new(:parent, :sortable => ["#{Issue.table_name}.root_id", "#{Issue.table_name}.lft ASC"], :default_order => 'desc', :caption => :field_parent_issue), |
28 |
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position", :groupable => true),
|
|
29 |
QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc', :groupable => true),
|
|
28 |
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.#{'position'.quote_column_name}", :groupable => true),
|
|
29 |
QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.#{'position'.quote_column_name}", :default_order => 'desc', :groupable => true),
|
|
30 | 30 |
QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"), |
31 | 31 |
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement("authors")}, :groupable => true), |
32 | 32 |
QueryColumn.new(:assigned_to, :sortable => lambda {User.fields_for_order_statement}, :groupable => true), |
app/models/issue_status.rb | ||
---|---|---|
95 | 95 |
subselect = "SELECT MAX(j.created_on) FROM #{Journal.table_name} j" + |
96 | 96 |
" JOIN #{JournalDetail.table_name} d ON d.journal_id = j.id" + |
97 | 97 |
" WHERE j.journalized_type = 'Issue' AND j.journalized_id = #{Issue.table_name}.id" + |
98 |
" AND d.property = 'attr' AND d.prop_key = 'status_id' AND d.value = :status_id"
|
|
98 |
" AND d.property = 'attr' AND d.prop_key = 'status_id' AND d.#{'value'.quote_column_name} = :status_id"
|
|
99 | 99 |
Issue.where(:status_id => id, :closed_on => nil). |
100 | 100 |
update_all(["closed_on = (#{subselect})", {:status_id => id.to_s}]) |
101 | 101 |
app/models/time_entry_query.rb | ||
---|---|---|
25 | 25 |
QueryColumn.new(:spent_on, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :default_order => 'desc', :groupable => true), |
26 | 26 |
QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :caption => l(:label_week)), |
27 | 27 |
QueryColumn.new(:user, :sortable => lambda {User.fields_for_order_statement}, :groupable => true), |
28 |
QueryColumn.new(:activity, :sortable => "#{TimeEntryActivity.table_name}.position", :groupable => true),
|
|
28 |
QueryColumn.new(:activity, :sortable => "#{TimeEntryActivity.table_name}.#{'position'.quote_column_name}", :groupable => true),
|
|
29 | 29 |
QueryColumn.new(:issue, :sortable => "#{Issue.table_name}.id"), |
30 |
QueryAssociationColumn.new(:issue, :tracker, :caption => :field_tracker, :sortable => "#{Tracker.table_name}.position"),
|
|
31 |
QueryAssociationColumn.new(:issue, :status, :caption => :field_status, :sortable => "#{IssueStatus.table_name}.position"),
|
|
30 |
QueryAssociationColumn.new(:issue, :tracker, :caption => :field_tracker, :sortable => "#{Tracker.table_name}.#{'position'.quote_column_name}"),
|
|
31 |
QueryAssociationColumn.new(:issue, :status, :caption => :field_status, :sortable => "#{IssueStatus.table_name}.#{'position'.quote_column_name}"),
|
|
32 | 32 |
QueryColumn.new(:comments), |
33 | 33 |
QueryColumn.new(:hours, :sortable => "#{TimeEntry.table_name}.hours", :totalable => true), |
34 | 34 |
] |
lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb | ||
---|---|---|
112 | 112 |
search_scope(user, projects, options). |
113 | 113 |
joins(:custom_values). |
114 | 114 |
where(visibility). |
115 |
where(search_tokens_condition(["#{CustomValue.table_name}.value"], tokens, options[:all_words])),
|
|
115 |
where(search_tokens_condition(["#{CustomValue.table_name}.#{'value'.quote_column_name}"], tokens, options[:all_words])),
|
|
116 | 116 |
options[:limit] |
117 | 117 |
) |
118 | 118 |
queries += 1 |
lib/redmine/acts/positioned.rb | ||
---|---|---|
84 | 84 |
end |
85 | 85 |
end |
86 | 86 | |
87 |
def position_column |
|
88 |
'position'.quote_column_name |
|
89 |
end |
|
90 | ||
87 | 91 |
def insert_position |
88 |
position_scope.where("position >= ? AND id <> ?", position, id).update_all("position = position + 1")
|
|
92 |
position_scope.where("#{position_column} >= ? AND id <> ?", position, id).update_all("#{position_column} = #{position_column} + 1")
|
|
89 | 93 |
end |
90 | 94 | |
91 | 95 |
def remove_position |
92 |
position_scope_was.where("position >= ? AND id <> ?", position_was, id).update_all("position = position - 1")
|
|
96 |
position_scope_was.where("#{position_column} >= ? AND id <> ?", position_was, id).update_all("#{position_column} = #{position_column} - 1")
|
|
93 | 97 |
end |
94 | 98 | |
95 | 99 |
def position_scope_changed? |
... | ... | |
99 | 103 |
def shift_positions |
100 | 104 |
offset = position_was <=> position |
101 | 105 |
min, max = [position, position_was].sort |
102 |
r = position_scope.where("id <> ? AND position BETWEEN ? AND ?", id, min, max).update_all("position = position + #{offset}")
|
|
106 |
r = position_scope.where("id <> ? AND #{position_column} BETWEEN ? AND ?", id, min, max).update_all("#{position_column} = #{position_column} + #{offset}")
|
|
103 | 107 |
if r != max - min |
104 | 108 |
reset_positions_in_list |
105 | 109 |
end |
lib/redmine/core_ext/string.rb | ||
---|---|---|
8 | 8 |
def is_binary_data? |
9 | 9 |
( self.count( "^ -~", "^\r\n" ).fdiv(self.size) > 0.3 || self.index( "\x00" ) ) unless empty? |
10 | 10 |
end |
11 | ||
12 |
def quote_column_name |
|
13 |
ActiveRecord::Base.connection.quote_column_name(self) |
|
14 |
end |
|
15 | ||
16 |
def quote_table_name |
|
17 |
ActiveRecord::Base.connection.quote_table_name(self) |
|
18 |
end |
|
11 | 19 |
end |
test/unit/query_test.rb | ||
---|---|---|
161 | 161 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
162 | 162 |
query.add_filter('fixed_version_id', '!*', ['']) |
163 | 163 |
query.add_filter('cf_1', '!*', ['']) |
164 |
value_col = 'value'.quote_column_name |
|
164 | 165 |
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NULL") |
165 |
assert query.statement.include?("#{CustomValue.table_name}.value IS NULL OR #{CustomValue.table_name}.value = ''")
|
|
166 |
assert query.statement.include?("#{CustomValue.table_name}.#{value_col} IS NULL OR #{CustomValue.table_name}.#{value_col} = ''")
|
|
166 | 167 |
find_issues_with_query(query) |
167 | 168 |
end |
168 | 169 | |
... | ... | |
196 | 197 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
197 | 198 |
query.add_filter('fixed_version_id', '*', ['']) |
198 | 199 |
query.add_filter('cf_1', '*', ['']) |
200 |
value_col = 'value'.quote_column_name |
|
199 | 201 |
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NOT NULL") |
200 |
assert query.statement.include?("#{CustomValue.table_name}.value IS NOT NULL AND #{CustomValue.table_name}.value <> ''")
|
|
202 |
assert query.statement.include?("#{CustomValue.table_name}.#{value_col} IS NOT NULL AND #{CustomValue.table_name}.#{value_col} <> ''")
|
|
201 | 203 |
find_issues_with_query(query) |
202 | 204 |
end |
203 | 205 |