|
|
|
@ -22,23 +22,27 @@ module Report::QueryUtils |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
# Graceful, internationalized quoted string. |
|
|
|
|
# Creates a SQL fragment representing a collection/array. |
|
|
|
|
# |
|
|
|
|
# @see quote_string |
|
|
|
|
# @param [Object] str String to quote/translate |
|
|
|
|
# @return [Object] Quoted, translated version |
|
|
|
|
def quoted_label(ident) |
|
|
|
|
"'#{quote_string l(ident)}'" |
|
|
|
|
# @param [#flatten] *values Ruby collection |
|
|
|
|
# @return [String] SQL collection |
|
|
|
|
def collection(*values) |
|
|
|
|
if values.empty? |
|
|
|
|
"" |
|
|
|
|
else |
|
|
|
|
"(#{values.flatten.map { |v| "'#{quote_string(v)}'" }.join ", "})" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
# Creates a SQL fragment representing a collection/array. |
|
|
|
|
# Graceful, internationalized quoted string. |
|
|
|
|
# |
|
|
|
|
# @see quote_string |
|
|
|
|
# @param [#flatten] *values Ruby collection |
|
|
|
|
# @return [String] SQL collection |
|
|
|
|
def collection(*values) |
|
|
|
|
"(#{values.flatten.map { |v| "'#{quote_string(v)}'" }.join ", "})" |
|
|
|
|
# @param [Object] str String to quote/translate |
|
|
|
|
# @return [Object] Quoted, translated version |
|
|
|
|
def quoted_label(ident) |
|
|
|
|
"'#{quote_string l(ident)}'" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def quoted_date(date) |
|
|
|
@ -84,6 +88,7 @@ module Report::QueryUtils |
|
|
|
|
# @return [String] Field name. |
|
|
|
|
def field_name_for(arg, default_table = nil) |
|
|
|
|
return 'NULL' unless arg |
|
|
|
|
return field_name_for(arg.keys.first, default_table) if arg.is_a? Hash |
|
|
|
|
return arg if arg.is_a? String and arg =~ /\.| |\(.*\)/ |
|
|
|
|
return table_name_for(arg.first || default_table) + '.' << arg.last.to_s if arg.is_a? Array and arg.size == 2 |
|
|
|
|
return arg.to_s unless default_table |
|
|
|
@ -97,10 +102,11 @@ module Report::QueryUtils |
|
|
|
|
# @param [Object] statement Not sanitized statement. |
|
|
|
|
# @return [String] Sanitized statement. |
|
|
|
|
def sanitize_sql_for_conditions(statement) |
|
|
|
|
Report.send :sanitize_sql_for_conditions, statement |
|
|
|
|
engine.send :sanitize_sql_for_conditions, statement |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
# FIXME: This is redmine |
|
|
|
|
# Generates string representation for a currency. |
|
|
|
|
# |
|
|
|
|
# @see CostRate.clean_currency |
|
|
|
|