39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/activerecord-analyze.rb', line 39
def self.build_prefix(opts = {})
format_sql = if fmt = opts[:format].presence
case fmt
when :json
"FORMAT JSON, "
when :hash
"FORMAT JSON, "
when :pretty_json
"FORMAT JSON, "
when :yaml
"FORMAT YAML, "
when :text
"FORMAT TEXT, "
when :xml
"FORMAT XML, "
else
""
end
end
verbose_sql = if opts[:verbose] == true
", VERBOSE"
end
costs_sql = if opts[:costs] == true
", COSTS"
end
settings_sql = if opts[:settings] == true
", SETTINGS"
end
buffers_sql = if opts[:buffers] == true
", BUFFERS"
end
timing_sql = if opts[:timing] == true
", TIMING"
end
summary_sql = if opts[:summary] == true
", SUMMARY"
end
analyze_sql = if opts[:analyze] == false
""
else
"ANALYZE"
end
opts_sql = "(#{format_sql}#{analyze_sql}#{verbose_sql}#{costs_sql}#{settings_sql}#{buffers_sql}#{timing_sql}#{summary_sql})"
.strip.gsub(/\s+/, " ")
.gsub(/\(\s?\s?\s?,/, "(")
.gsub(/\s,\s/, " ")
.gsub(/\(\s?\)/, "")
end
|