Patch #25066 » Added_null_placement_at_order_statement_v2.patch
app/models/query.rb (date 1487680385000) | ||
---|---|---|
716 | 716 |
arg = arg.keys.sort.collect {|k| arg[k]} |
717 | 717 |
end |
718 | 718 |
if arg |
719 |
c = arg.select {|k,o| !k.to_s.blank?}.slice(0,3).collect {|k,o| [k.to_s, (o == 'desc' || o == false) ? 'desc' : 'asc']}
|
|
719 |
c = arg.select { |k, o| !k.to_s.blank? }.slice(0, 3).collect { |k, o| [k.to_s, o.to_s.empty? ? 'asc' : o.to_s] }
|
|
720 | 720 |
end |
721 | 721 |
write_attribute(:sort_criteria, c) |
722 | 722 |
end |
... | ... | |
984 | 984 |
" SELECT customized_id FROM #{CustomValue.table_name}" + |
985 | 985 |
" WHERE customized_type='#{target_class}' AND custom_field_id=#{chained_custom_field_id}" + |
986 | 986 |
" AND #{sql_for_field(field, operator, value, CustomValue.table_name, 'value')}))" |
987 |
|
|
987 |
|
|
988 | 988 |
end |
989 | 989 |
|
990 | 990 |
def sql_for_custom_field_attribute(field, operator, value, custom_field_id, attribute) |
config/locales/ar.yml (date 1487680385000) | ||
---|---|---|
1229 | 1229 |
field_updated_by: Updated by |
1230 | 1230 |
field_last_updated_by: Last updated by |
1231 | 1231 |
field_full_width_layout: Full width layout |
1232 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1233 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/az.yml (date 1487680385000) | ||
---|---|---|
1324 | 1324 |
field_updated_by: Updated by |
1325 | 1325 |
field_last_updated_by: Last updated by |
1326 | 1326 |
field_full_width_layout: Full width layout |
1327 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1328 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/bg.yml (date 1487680385000) | ||
---|---|---|
1213 | 1213 |
description_date_from: Въведете начална дата |
1214 | 1214 |
description_date_to: Въведете крайна дата |
1215 | 1215 |
text_repository_identifier_info: 'Позволени са малки букви (a-z), цифри, тирета и _.<br />Промяна след създаването му не е възможна.' |
1216 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1217 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/bs.yml (date 1487680385000) | ||
---|---|---|
1242 | 1242 |
field_updated_by: Updated by |
1243 | 1243 |
field_last_updated_by: Last updated by |
1244 | 1244 |
field_full_width_layout: Full width layout |
1245 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1246 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/ca.yml (date 1487680385000) | ||
---|---|---|
1219 | 1219 |
field_updated_by: Updated by |
1220 | 1220 |
field_last_updated_by: Last updated by |
1221 | 1221 |
field_full_width_layout: Full width layout |
1222 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1223 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/cs.yml (date 1487680385000) | ||
---|---|---|
1228 | 1228 |
field_updated_by: Updated by |
1229 | 1229 |
field_last_updated_by: Last updated by |
1230 | 1230 |
field_full_width_layout: Full width layout |
1231 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1232 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/da.yml (date 1487680385000) | ||
---|---|---|
1246 | 1246 |
field_updated_by: Updated by |
1247 | 1247 |
field_last_updated_by: Last updated by |
1248 | 1248 |
field_full_width_layout: Full width layout |
1249 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1250 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/de.yml (date 1487680385000) | ||
---|---|---|
1231 | 1231 |
field_updated_by: Updated by |
1232 | 1232 |
field_last_updated_by: Last updated by |
1233 | 1233 |
field_full_width_layout: Full width layout |
1234 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1235 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/el.yml (date 1487680385000) | ||
---|---|---|
1229 | 1229 |
field_updated_by: Updated by |
1230 | 1230 |
field_last_updated_by: Last updated by |
1231 | 1231 |
field_full_width_layout: Full width layout |
1232 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1233 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/en.yml (date 1487680385000) | ||
---|---|---|
898 | 898 |
label_sort: Sort |
899 | 899 |
label_ascending: Ascending |
900 | 900 |
label_descending: Descending |
901 |
label_ascending_nulls_last: Ascending with null values at the end |
|
902 |
label_descending_nulls_first: Descending with null values at the top |
|
901 | 903 |
label_date_from_to: From %{start} to %{end} |
902 | 904 |
label_wiki_content_added: Wiki page added |
903 | 905 |
label_wiki_content_updated: Wiki page updated |
config/locales/es.yml (date 1487680385000) | ||
---|---|---|
1257 | 1257 |
field_updated_by: Updated by |
1258 | 1258 |
field_last_updated_by: Last updated by |
1259 | 1259 |
field_full_width_layout: Full width layout |
1260 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1261 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/et.yml (date 1487680385000) | ||
---|---|---|
1234 | 1234 |
field_updated_by: Updated by |
1235 | 1235 |
field_last_updated_by: Last updated by |
1236 | 1236 |
field_full_width_layout: Full width layout |
1237 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1238 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/eu.yml (date 1487680385000) | ||
---|---|---|
1230 | 1230 |
field_updated_by: Updated by |
1231 | 1231 |
field_last_updated_by: Last updated by |
1232 | 1232 |
field_full_width_layout: Full width layout |
1233 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1234 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/fa.yml (date 1487680385000) | ||
---|---|---|
1230 | 1230 |
field_updated_by: Updated by |
1231 | 1231 |
field_last_updated_by: Last updated by |
1232 | 1232 |
field_full_width_layout: Full width layout |
1233 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1234 |
label_descending_nulls_first: Descending with null values at the top\ |
config/locales/fi.yml (date 1487680385000) | ||
---|---|---|
1250 | 1250 |
field_updated_by: Updated by |
1251 | 1251 |
field_last_updated_by: Last updated by |
1252 | 1252 |
field_full_width_layout: Full width layout |
1253 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1254 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/fr.yml (date 1487680385000) | ||
---|---|---|
1230 | 1230 |
label_no_preview: No preview available |
1231 | 1231 |
label_user_mail_option_only_assigned: Only for things I watch or I am assigned to |
1232 | 1232 |
label_user_mail_option_only_owner: Only for things I watch or I am the owner of |
1233 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1234 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/gl.yml (date 1487680385000) | ||
---|---|---|
1237 | 1237 |
field_updated_by: Updated by |
1238 | 1238 |
field_last_updated_by: Last updated by |
1239 | 1239 |
field_full_width_layout: Full width layout |
1240 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1241 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/he.yml (date 1487680385000) | ||
---|---|---|
1234 | 1234 |
field_updated_by: Updated by |
1235 | 1235 |
field_last_updated_by: Last updated by |
1236 | 1236 |
field_full_width_layout: Full width layout |
1237 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1238 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/hr.yml (date 1487680385000) | ||
---|---|---|
1228 | 1228 |
field_updated_by: Updated by |
1229 | 1229 |
field_last_updated_by: Last updated by |
1230 | 1230 |
field_full_width_layout: Full width layout |
1231 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1232 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/hu.yml (date 1487680385000) | ||
---|---|---|
1248 | 1248 |
field_updated_by: Updated by |
1249 | 1249 |
field_last_updated_by: Last updated by |
1250 | 1250 |
field_full_width_layout: Full width layout |
1251 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1252 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/id.yml (date 1487680385000) | ||
---|---|---|
1233 | 1233 |
field_updated_by: Updated by |
1234 | 1234 |
field_last_updated_by: Last updated by |
1235 | 1235 |
field_full_width_layout: Full width layout |
1236 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1237 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/it.yml (date 1487680385000) | ||
---|---|---|
1224 | 1224 |
field_updated_by: Updated by |
1225 | 1225 |
field_last_updated_by: Last updated by |
1226 | 1226 |
field_full_width_layout: Full width layout |
1227 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1228 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/ja.yml (date 1487680385000) | ||
---|---|---|
1236 | 1236 |
field_updated_by: 更新者 |
1237 | 1237 |
field_last_updated_by: 最終更新者 |
1238 | 1238 |
field_full_width_layout: ワイド表示 |
1239 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1240 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/ko.yml (date 1487680385000) | ||
---|---|---|
1268 | 1268 |
field_updated_by: Updated by |
1269 | 1269 |
field_last_updated_by: Last updated by |
1270 | 1270 |
field_full_width_layout: Full width layout |
1271 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1272 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/lt.yml (date 1487680385000) | ||
---|---|---|
1218 | 1218 |
field_updated_by: Updated by |
1219 | 1219 |
field_last_updated_by: Last updated by |
1220 | 1220 |
field_full_width_layout: Full width layout |
1221 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1222 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/lv.yml (date 1487680385000) | ||
---|---|---|
1223 | 1223 |
field_updated_by: Updated by |
1224 | 1224 |
field_last_updated_by: Last updated by |
1225 | 1225 |
field_full_width_layout: Full width layout |
1226 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1227 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/mk.yml (date 1487680385000) | ||
---|---|---|
1229 | 1229 |
field_updated_by: Updated by |
1230 | 1230 |
field_last_updated_by: Last updated by |
1231 | 1231 |
field_full_width_layout: Full width layout |
1232 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1233 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/mn.yml (date 1487680385000) | ||
---|---|---|
1230 | 1230 |
field_updated_by: Updated by |
1231 | 1231 |
field_last_updated_by: Last updated by |
1232 | 1232 |
field_full_width_layout: Full width layout |
1233 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1234 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/nl.yml (date 1487680385000) | ||
---|---|---|
1204 | 1204 |
field_updated_by: Updated by |
1205 | 1205 |
field_last_updated_by: Last updated by |
1206 | 1206 |
field_full_width_layout: Full width layout |
1207 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1208 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/no.yml (date 1487680385000) | ||
---|---|---|
1219 | 1219 |
field_updated_by: Updated by |
1220 | 1220 |
field_last_updated_by: Last updated by |
1221 | 1221 |
field_full_width_layout: Full width layout |
1222 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1223 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/pl.yml (date 1487680385000) | ||
---|---|---|
1244 | 1244 |
field_updated_by: Updated by |
1245 | 1245 |
field_last_updated_by: Last updated by |
1246 | 1246 |
field_full_width_layout: Full width layout |
1247 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1248 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/pt.yml (date 1487680385000) | ||
---|---|---|
1232 | 1232 |
field_updated_by: Updated by |
1233 | 1233 |
field_last_updated_by: Last updated by |
1234 | 1234 |
field_full_width_layout: Full width layout |
1235 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1236 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/ro.yml (date 1487680385000) | ||
---|---|---|
13 | 13 |
month_names: [~, Ianuarie, Februarie, Martie, Aprilie, Mai, Iunie, Iulie, August, Septembrie, Octombrie, Noiembrie, Decembrie] |
14 | 14 |
abbr_month_names: [~, Ian, Feb, Mar, Apr, Mai, Iun, Iul, Aug, Sep, Oct, Noi, Dec] |
15 | 15 |
order: |
16 |
- :day |
|
17 |
- :month |
|
16 |
- :day- :month |
|
18 | 17 |
- :year |
19 | 18 |
|
20 | 19 |
time: |
... | ... | |
1224 | 1223 |
field_updated_by: Updated by |
1225 | 1224 |
field_last_updated_by: Last updated by |
1226 | 1225 |
field_full_width_layout: Full width layout |
1226 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1227 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/ru.yml (date 1487680385000) | ||
---|---|---|
1331 | 1331 |
field_updated_by: Updated by |
1332 | 1332 |
field_last_updated_by: Last updated by |
1333 | 1333 |
field_full_width_layout: Full width layout |
1334 |
label_ascending_nulls_last: По возрастанию с пустыми значениями в конце |
|
1335 |
label_descending_nulls_first: По убыванию с пустыми значениями в начале |
config/locales/sk.yml (date 1487680385000) | ||
---|---|---|
1219 | 1219 |
field_updated_by: Updated by |
1220 | 1220 |
field_last_updated_by: Last updated by |
1221 | 1221 |
field_full_width_layout: Full width layout |
1222 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1223 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/sl.yml (date 1487680385000) | ||
---|---|---|
1229 | 1229 |
field_updated_by: Updated by |
1230 | 1230 |
field_last_updated_by: Last updated by |
1231 | 1231 |
field_full_width_layout: Full width layout |
1232 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1233 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/sq.yml (date 1487680385000) | ||
---|---|---|
1225 | 1225 |
field_updated_by: Updated by |
1226 | 1226 |
field_last_updated_by: Last updated by |
1227 | 1227 |
field_full_width_layout: Full width layout |
1228 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1229 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/sr.yml (date 1487680385000) | ||
---|---|---|
1230 | 1230 |
field_updated_by: Updated by |
1231 | 1231 |
field_last_updated_by: Last updated by |
1232 | 1232 |
field_full_width_layout: Full width layout |
1233 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1234 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/sv.yml (date 1487680385000) | ||
---|---|---|
1262 | 1262 |
field_updated_by: Updated by |
1263 | 1263 |
field_last_updated_by: Last updated by |
1264 | 1264 |
field_full_width_layout: Full width layout |
1265 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1266 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/th.yml (date 1487680385000) | ||
---|---|---|
1226 | 1226 |
field_updated_by: Updated by |
1227 | 1227 |
field_last_updated_by: Last updated by |
1228 | 1228 |
field_full_width_layout: Full width layout |
1229 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1230 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/tr.yml (date 1487680385000) | ||
---|---|---|
1237 | 1237 |
field_updated_by: Updated by |
1238 | 1238 |
field_last_updated_by: Last updated by |
1239 | 1239 |
field_full_width_layout: Full width layout |
1240 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1241 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/uk.yml (date 1487680385000) | ||
---|---|---|
1224 | 1224 |
field_updated_by: Updated by |
1225 | 1225 |
field_last_updated_by: Last updated by |
1226 | 1226 |
field_full_width_layout: Full width layout |
1227 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1228 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/vi.yml (date 1487680385000) | ||
---|---|---|
1282 | 1282 |
field_updated_by: Updated by |
1283 | 1283 |
field_last_updated_by: Last updated by |
1284 | 1284 |
field_full_width_layout: Full width layout |
1285 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1286 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/zh.yml (date 1487680385000) | ||
---|---|---|
1222 | 1222 |
field_updated_by: Updated by |
1223 | 1223 |
field_last_updated_by: Last updated by |
1224 | 1224 |
field_full_width_layout: Full width layout |
1225 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1226 |
label_descending_nulls_first: Descending with null values at the top |
lib/redmine/database.rb (date 1487680385000) | ||
---|---|---|
49 | 49 |
(ActiveRecord::Base.connection.adapter_name =~ /mysql/i).present? |
50 | 50 |
end |
51 | 51 |
|
52 |
def sqlite3? |
|
53 |
(ActiveRecord::Base.connection.adapter_name =~ /sqlite/i).present? |
|
54 |
end |
|
55 |
|
|
56 |
def sqlserver? |
|
57 |
(ActiveRecord::Base.connection.adapter_name =~ /sqlserver/i).present? |
|
58 |
end |
|
59 |
|
|
52 | 60 |
# Returns a SQL statement for case/accent (if possible) insensitive match |
53 | 61 |
def like(left, right, options={}) |
54 | 62 |
neg = (options[:match] == false ? 'NOT ' : '') |
... | ... | |
64 | 72 |
end |
65 | 73 |
end |
66 | 74 |
|
75 |
def firebird? |
|
76 |
(ActiveRecord::Base.connection.adapter_name =~ /firebird/i).present? |
|
77 |
end |
|
78 |
|
|
67 | 79 |
# Resets database information |
68 | 80 |
def reset |
69 | 81 |
@postgresql_unaccent = nil |
config/locales/en-GB.yml (date 1487680385000) | ||
---|---|---|
1231 | 1231 |
field_updated_by: Updated by |
1232 | 1232 |
field_last_updated_by: Last updated by |
1233 | 1233 |
field_full_width_layout: Full width layout |
1234 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1235 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/es-PA.yml (date 1487680385000) | ||
---|---|---|
1259 | 1259 |
field_updated_by: Updated by |
1260 | 1260 |
field_last_updated_by: Last updated by |
1261 | 1261 |
field_full_width_layout: Full width layout |
1262 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1263 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/pt-BR.yml (date 1487680385000) | ||
---|---|---|
1247 | 1247 |
field_updated_by: Updated by |
1248 | 1248 |
field_last_updated_by: Last updated by |
1249 | 1249 |
field_full_width_layout: Full width layout |
1250 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1251 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/sr-YU.yml (date 1487680385000) | ||
---|---|---|
1231 | 1231 |
field_updated_by: Updated by |
1232 | 1232 |
field_last_updated_by: Last updated by |
1233 | 1233 |
field_full_width_layout: Full width layout |
1234 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1235 |
label_descending_nulls_first: Descending with null values at the top |
config/locales/zh-TW.yml (date 1487680385000) | ||
---|---|---|
1296 | 1296 |
description_date_from: 輸入起始日期 |
1297 | 1297 |
description_date_to: 輸入結束日期 |
1298 | 1298 |
text_repository_identifier_info: '僅允許使用小寫英文字母 (a-z), 阿拉伯數字, 虛線與底線。<br />一旦儲存之後, 代碼便無法再次被更改。' |
1299 |
label_ascending_nulls_last: Ascending with null values at the end |
|
1300 |
label_descending_nulls_first: Descending with null values at the top |
app/helpers/sort_helper.rb (date 1487680385000) | ||
---|---|---|
61 | 61 |
|
62 | 62 |
def available_criteria=(criteria) |
63 | 63 |
unless criteria.is_a?(Hash) |
64 |
criteria = criteria.inject({}) {|h,k| h[k] = k; h}
|
|
64 |
criteria = criteria.inject({}) { |h, k| h[k] = k; h }
|
|
65 | 65 |
end |
66 | 66 |
@available_criteria = criteria |
67 | 67 |
end |
68 | 68 |
|
69 | 69 |
def from_param(param) |
70 |
@criteria = param.to_s.split(',').collect {|s| s.split(':')[0..1]}
|
|
70 |
@criteria = param.to_s.split(',').collect { |s| s.split(':')[0..1] }
|
|
71 | 71 |
normalize! |
72 | 72 |
end |
73 | 73 |
|
... | ... | |
77 | 77 |
end |
78 | 78 |
|
79 | 79 |
def to_param |
80 |
@criteria.collect {|k,o| k + (o ? '' : ':desc')}.join(',')
|
|
80 |
@criteria.collect { |k, o| k + ":#{o.to_s}" }.join(',')
|
|
81 | 81 |
end |
82 | 82 |
|
83 | 83 |
# Returns an array of SQL fragments used to sort the list |
84 | 84 |
def to_sql |
85 |
sql = @criteria.collect do |k,o| |
|
85 |
sql = @criteria.collect do |k, o|
|
|
86 | 86 |
if s = @available_criteria[k] |
87 | 87 |
s = [s] unless s.is_a?(Array) |
88 |
s.collect {|c| append_order(c, o ? "ASC" : "DESC")}
|
|
88 |
s.collect { |c| append_order(c, o.to_s.upcase) }
|
|
89 | 89 |
end |
90 | 90 |
end.flatten.compact |
91 | 91 |
sql.blank? ? nil : sql |
... | ... | |
96 | 96 |
end |
97 | 97 |
|
98 | 98 |
def add!(key, asc) |
99 |
@criteria.delete_if {|k,o| k == key}
|
|
99 |
@criteria.delete_if { |k, o| k == key }
|
|
100 | 100 |
@criteria = [[key, asc]] + @criteria |
101 | 101 |
normalize! |
102 | 102 |
end |
... | ... | |
112 | 112 |
end |
113 | 113 |
|
114 | 114 |
def first_asc? |
115 |
@criteria.first && @criteria.first.last |
|
115 |
@criteria.first && @criteria.first.last.to_s.downcase.start_with?("asc")
|
|
116 | 116 |
end |
117 | 117 |
|
118 | 118 |
def empty? |
... | ... | |
123 | 123 |
|
124 | 124 |
def normalize! |
125 | 125 |
@criteria ||= [] |
126 |
@criteria = @criteria.collect {|s| s = Array(s); [s.first, (s.last == false || s.last == 'desc') ? false : true]} |
|
127 |
@criteria = @criteria.select {|k,o| @available_criteria.has_key?(k)} if @available_criteria |
|
126 |
@criteria = @criteria.collect { |s| s = Array(s); [s.first, s[1].nil? ? 'asc' : |
|
127 |
(s.last.to_s.downcase.start_with?('desc', 'asc')? s.last.to_s : 'asc')] } |
|
128 |
@criteria = @criteria.select { |k, o| @available_criteria.has_key?(k) } if @available_criteria |
|
128 | 129 |
@criteria.slice!(3) |
129 | 130 |
self |
130 | 131 |
end |
... | ... | |
134 | 135 |
if criterion =~ / (asc|desc)$/i |
135 | 136 |
criterion |
136 | 137 |
else |
137 |
"#{criterion} #{order}" |
|
138 |
if (order =~ /nulls/i).present? |
|
139 |
t = order.to_s.split(' ') |
|
140 |
sort_order = t.first |
|
141 |
nulls_last = t.last.to_s.downcase.eql?("last") |
|
142 |
if Redmine::Database.mysql? |
|
143 |
"ISNULL(#{criterion}) #{nulls_last ? "ASC" : "DESC"}, #{criterion} #{sort_order}" |
|
144 |
elsif Redmine::Database.sqlserver? || Redmine::Database.sqlite3? |
|
145 |
"#{criterion} IS NULL #{nulls_last ? "ASC" : "DESC"}, #{criterion} #{sort_order}" |
|
146 |
else |
|
147 |
"#{criterion} #{order}" |
|
148 |
end |
|
149 |
else |
|
150 |
"#{criterion} #{order}" |
|
151 |
end |
|
138 | 152 |
end |
139 | 153 |
end |
140 | 154 |
|
... | ... | |
158 | 172 |
# |
159 | 173 |
def sort_init(*args) |
160 | 174 |
case args.size |
161 |
when 1 |
|
162 |
@sort_default = args.first.is_a?(Array) ? args.first : [[args.first]] |
|
163 |
when 2 |
|
164 |
@sort_default = [[args.first, args.last]] |
|
165 |
else |
|
166 |
raise ArgumentError |
|
175 |
when 1
|
|
176 |
@sort_default = args.first.is_a?(Array) ? args.first : [[args.first]]
|
|
177 |
when 2
|
|
178 |
@sort_default = [[args.first, args.last]]
|
|
179 |
else
|
|
180 |
raise ArgumentError
|
|
167 | 181 |
end |
168 | 182 |
end |
169 | 183 |
|
... | ... | |
217 | 231 |
end |
218 | 232 |
caption = column.to_s.humanize unless caption |
219 | 233 |
|
220 |
sort_options = { :sort => @sort_criteria.add(column.to_s, order).to_param }
|
|
234 |
sort_options = {:sort => @sort_criteria.add(column.to_s, order).to_param}
|
|
221 | 235 |
link_to(caption, {:params => request.query_parameters.merge(sort_options)}, :class => css) |
222 | 236 |
end |
223 | 237 |
|
lib/redmine/field_format.rb (date 1487680385000) | ||
---|---|---|
293 | 293 |
# objects by their value of the custom field. |
294 | 294 |
# Returns nil if the custom field can not be used for sorting. |
295 | 295 |
def order_statement(custom_field) |
296 |
# COALESCE is here to make sure that blank and NULL values are sorted equally |
|
297 |
"COALESCE(#{join_alias custom_field}.value, '')" |
|
296 |
"#{join_alias custom_field}.value" #COALESCE removed to allow null placement on order |
|
298 | 297 |
end |
299 | 298 |
|
300 | 299 |
# Returns a GROUP BY clause that can used to group by custom value |
app/views/queries/_form.html.erb (date 1487680385000) | ||
---|---|---|
63 | 63 |
<%= label_tag "query_sort_criteria_direction_" + i.to_s, |
64 | 64 |
l(:description_query_sort_criteria_direction), :class => "hidden-for-sighted" %> |
65 | 65 |
<%= select_tag("query[sort_criteria][#{i}][]", |
66 |
options_for_select([[], [l(:label_ascending), 'asc'], [l(:label_descending), 'desc']], @query.sort_criteria_order(i)), |
|
66 |
options_for_select([[], [l(:label_ascending), 'asc'], [l(:label_descending), 'desc'], [l(:label_ascending_nulls_last), 'asc nulls last'], [l(:label_descending_nulls_first), 'desc nulls first']], @query.sort_criteria_order(i)),
|
|
67 | 67 |
:id => "query_sort_criteria_direction_" + i.to_s) %> |
68 | 68 |
<br /> |
69 | 69 |
<% end %> |