activerecord-sqlserver-adapter 2.3.7 → 3.2.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +385 -61
- data/MIT-LICENSE +1 -1
- data/VERSION +1 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/active_record.rb +42 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/database_statements.rb +97 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb +41 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/explain_subscriber.rb +26 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/odbc.rb +38 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/relation.rb +19 -0
- data/lib/active_record/connection_adapters/sqlserver/database_limits.rb +49 -0
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +458 -0
- data/lib/active_record/connection_adapters/sqlserver/errors.rb +36 -0
- data/lib/active_record/connection_adapters/sqlserver/quoting.rb +113 -0
- data/lib/active_record/connection_adapters/sqlserver/schema_cache.rb +85 -0
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +376 -0
- data/lib/active_record/connection_adapters/sqlserver/showplan/printer_table.rb +69 -0
- data/lib/active_record/connection_adapters/sqlserver/showplan/printer_xml.rb +25 -0
- data/lib/active_record/connection_adapters/sqlserver/showplan.rb +67 -0
- data/lib/active_record/connection_adapters/sqlserver/utils.rb +32 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +344 -1055
- data/lib/arel/visitors/sqlserver.rb +389 -0
- metadata +60 -83
- data/README.rdoc +0 -190
- data/RUNNING_UNIT_TESTS +0 -65
- data/Rakefile +0 -41
- data/autotest/discover.rb +0 -4
- data/autotest/railssqlserver.rb +0 -16
- data/autotest/sqlserver.rb +0 -54
- data/lib/active_record/connection_adapters/sqlserver_adapter/core_ext/active_record.rb +0 -151
- data/lib/active_record/connection_adapters/sqlserver_adapter/core_ext/odbc.rb +0 -40
- data/test/cases/aaaa_create_tables_test_sqlserver.rb +0 -19
- data/test/cases/adapter_test_sqlserver.rb +0 -756
- data/test/cases/attribute_methods_test_sqlserver.rb +0 -33
- data/test/cases/basics_test_sqlserver.rb +0 -21
- data/test/cases/calculations_test_sqlserver.rb +0 -20
- data/test/cases/column_test_sqlserver.rb +0 -285
- data/test/cases/connection_test_sqlserver.rb +0 -146
- data/test/cases/eager_association_test_sqlserver.rb +0 -42
- data/test/cases/execute_procedure_test_sqlserver.rb +0 -44
- data/test/cases/inheritance_test_sqlserver.rb +0 -28
- data/test/cases/method_scoping_test_sqlserver.rb +0 -28
- data/test/cases/migration_test_sqlserver.rb +0 -123
- data/test/cases/named_scope_test_sqlserver.rb +0 -21
- data/test/cases/offset_and_limit_test_sqlserver.rb +0 -108
- data/test/cases/pessimistic_locking_test_sqlserver.rb +0 -125
- data/test/cases/query_cache_test_sqlserver.rb +0 -24
- data/test/cases/schema_dumper_test_sqlserver.rb +0 -72
- data/test/cases/specific_schema_test_sqlserver.rb +0 -97
- data/test/cases/sqlserver_helper.rb +0 -127
- data/test/cases/table_name_test_sqlserver.rb +0 -38
- data/test/cases/transaction_test_sqlserver.rb +0 -93
- data/test/cases/unicode_test_sqlserver.rb +0 -50
- data/test/cases/validations_test_sqlserver.rb +0 -35
- data/test/connections/native_sqlserver/connection.rb +0 -25
- data/test/connections/native_sqlserver_odbc/connection.rb +0 -27
- data/test/migrations/transaction_table/1_table_will_never_be_created.rb +0 -11
- data/test/schema/sqlserver_specific_schema.rb +0 -94
@@ -0,0 +1,389 @@
|
|
1
|
+
require 'arel'
|
2
|
+
|
3
|
+
module Arel
|
4
|
+
|
5
|
+
module Nodes
|
6
|
+
|
7
|
+
# Extending the Ordering class to be comparrison friendly which allows us to call #uniq on a
|
8
|
+
# collection of them. See SelectManager#order for more details.
|
9
|
+
class Ordering < Arel::Nodes::Unary
|
10
|
+
def hash
|
11
|
+
expr.hash
|
12
|
+
end
|
13
|
+
def ==(other)
|
14
|
+
other.is_a?(Arel::Nodes::Ordering) && self.expr == other.expr
|
15
|
+
end
|
16
|
+
def eql?(other)
|
17
|
+
self == other
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class SelectManager < Arel::TreeManager
|
24
|
+
|
25
|
+
AR_CA_SQLSA_NAME = 'ActiveRecord::ConnectionAdapters::SQLServerAdapter'.freeze
|
26
|
+
|
27
|
+
# Getting real Ordering objects is very important for us. We need to be able to call #uniq on
|
28
|
+
# a colleciton of them reliably as well as using their true object attributes to mutate them
|
29
|
+
# to grouping objects for the inner sql during a select statment with an offset/rownumber. So this
|
30
|
+
# is here till ActiveRecord & ARel does this for us instead of using SqlLiteral objects.
|
31
|
+
alias :order_without_sqlserver :order
|
32
|
+
def order(*expr)
|
33
|
+
return order_without_sqlserver(*expr) unless engine_activerecord_sqlserver_adapter?
|
34
|
+
@ast.orders.concat(expr.map{ |x|
|
35
|
+
case x
|
36
|
+
when Arel::Attributes::Attribute
|
37
|
+
table = Arel::Table.new(x.relation.table_alias || x.relation.name)
|
38
|
+
e = table[x.name]
|
39
|
+
Arel::Nodes::Ascending.new e
|
40
|
+
when Arel::Nodes::Ordering
|
41
|
+
x
|
42
|
+
when String
|
43
|
+
x.split(',').map do |s|
|
44
|
+
s = x if x.strip =~ /\A\b\w+\b\(.*,.*\)(\s+(ASC|DESC))?\Z/i # Allow functions with comma(s) to pass thru.
|
45
|
+
s.strip!
|
46
|
+
d = s =~ /(ASC|DESC)\Z/i ? $1.upcase : nil
|
47
|
+
e = d.nil? ? s : s.mb_chars[0...-d.length].strip
|
48
|
+
e = Arel.sql(e)
|
49
|
+
d && d == "DESC" ? Arel::Nodes::Descending.new(e) : Arel::Nodes::Ascending.new(e)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
e = Arel.sql(x.to_s)
|
53
|
+
Arel::Nodes::Ascending.new e
|
54
|
+
end
|
55
|
+
}.flatten)
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
# A friendly over ride that allows us to put a special lock object that can have a default or pass
|
60
|
+
# custom string hints down. See the visit_Arel_Nodes_LockWithSQLServer delegation method.
|
61
|
+
alias :lock_without_sqlserver :lock
|
62
|
+
def lock(locking=true)
|
63
|
+
if engine_activerecord_sqlserver_adapter?
|
64
|
+
case locking
|
65
|
+
when true
|
66
|
+
locking = Arel.sql('WITH(HOLDLOCK, ROWLOCK)')
|
67
|
+
when Arel::Nodes::SqlLiteral
|
68
|
+
when String
|
69
|
+
locking = Arel.sql locking
|
70
|
+
end
|
71
|
+
@ast.lock = Arel::Nodes::Lock.new(locking)
|
72
|
+
self
|
73
|
+
else
|
74
|
+
lock_without_sqlserver(locking)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def engine_activerecord_sqlserver_adapter?
|
81
|
+
@engine.connection && @engine.connection.class.name == AR_CA_SQLSA_NAME
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
module Visitors
|
87
|
+
class SQLServer < Arel::Visitors::ToSql
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
# SQLServer ToSql/Visitor (Overides)
|
92
|
+
|
93
|
+
def visit_Arel_Nodes_SelectStatement(o)
|
94
|
+
if complex_count_sql?(o)
|
95
|
+
visit_Arel_Nodes_SelectStatementForComplexCount(o)
|
96
|
+
elsif o.offset
|
97
|
+
visit_Arel_Nodes_SelectStatementWithOffset(o)
|
98
|
+
else
|
99
|
+
visit_Arel_Nodes_SelectStatementWithOutOffset(o)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def visit_Arel_Nodes_UpdateStatement(o)
|
104
|
+
if o.orders.any? && o.limit.nil?
|
105
|
+
o.limit = Nodes::Limit.new(9223372036854775807)
|
106
|
+
end
|
107
|
+
super
|
108
|
+
end
|
109
|
+
|
110
|
+
def visit_Arel_Nodes_Offset(o)
|
111
|
+
"WHERE [__rnt].[__rn] > (#{visit o.expr})"
|
112
|
+
end
|
113
|
+
|
114
|
+
def visit_Arel_Nodes_Limit(o)
|
115
|
+
"TOP (#{visit o.expr})"
|
116
|
+
end
|
117
|
+
|
118
|
+
def visit_Arel_Nodes_Lock(o)
|
119
|
+
visit o.expr
|
120
|
+
end
|
121
|
+
|
122
|
+
def visit_Arel_Nodes_Ordering(o)
|
123
|
+
if o.respond_to?(:direction)
|
124
|
+
"#{visit o.expr} #{o.ascending? ? 'ASC' : 'DESC'}"
|
125
|
+
else
|
126
|
+
visit o.expr
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def visit_Arel_Nodes_Bin(o)
|
131
|
+
"#{visit o.expr} #{@connection.cs_equality_operator}"
|
132
|
+
end
|
133
|
+
|
134
|
+
# SQLServer ToSql/Visitor (Additions)
|
135
|
+
|
136
|
+
def visit_Arel_Nodes_SelectStatementWithOutOffset(o, windowed=false)
|
137
|
+
find_and_fix_uncorrelated_joins_in_select_statement(o)
|
138
|
+
core = o.cores.first
|
139
|
+
projections = core.projections
|
140
|
+
groups = core.groups
|
141
|
+
orders = o.orders.uniq
|
142
|
+
if windowed
|
143
|
+
projections = function_select_statement?(o) ? projections : projections.map { |x| projection_without_expression(x) }
|
144
|
+
groups = projections.map { |x| projection_without_expression(x) } if windowed_single_distinct_select_statement?(o) && groups.empty?
|
145
|
+
groups += orders.map { |x| Arel.sql(x.expr) } if windowed_single_distinct_select_statement?(o)
|
146
|
+
elsif eager_limiting_select_statement?(o)
|
147
|
+
projections = projections.map { |x| projection_without_expression(x) }
|
148
|
+
groups = projections.map { |x| projection_without_expression(x) }
|
149
|
+
orders = orders.map do |x|
|
150
|
+
expr = Arel.sql projection_without_expression(x.expr)
|
151
|
+
x.descending? ? Arel::Nodes::Max.new([expr]) : Arel::Nodes::Min.new([expr])
|
152
|
+
end
|
153
|
+
elsif top_one_everything_for_through_join?(o)
|
154
|
+
projections = projections.map { |x| projection_without_expression(x) }
|
155
|
+
end
|
156
|
+
[ ("SELECT" if !windowed),
|
157
|
+
(visit(core.set_quantifier) if core.set_quantifier && !windowed),
|
158
|
+
(visit(o.limit) if o.limit && !windowed),
|
159
|
+
(projections.map{ |x| v = visit(x); v == "1" ? "1 AS [__wrp]" : v }.join(', ')),
|
160
|
+
(source_with_lock_for_select_statement(o)),
|
161
|
+
("WHERE #{core.wheres.map{ |x| visit(x) }.join ' AND ' }" unless core.wheres.empty?),
|
162
|
+
("GROUP BY #{groups.map { |x| visit x }.join ', ' }" unless groups.empty?),
|
163
|
+
(visit(core.having) if core.having),
|
164
|
+
("ORDER BY #{orders.map{ |x| visit(x) }.join(', ')}" if !orders.empty? && !windowed)
|
165
|
+
].compact.join ' '
|
166
|
+
end
|
167
|
+
|
168
|
+
def visit_Arel_Nodes_SelectStatementWithOffset(o)
|
169
|
+
core = o.cores.first
|
170
|
+
o.limit ||= Arel::Nodes::Limit.new(9223372036854775807)
|
171
|
+
orders = rowtable_orders(o)
|
172
|
+
[ "SELECT",
|
173
|
+
(visit(o.limit) if o.limit && !windowed_single_distinct_select_statement?(o)),
|
174
|
+
(rowtable_projections(o).map{ |x| visit(x) }.join(', ')),
|
175
|
+
"FROM (",
|
176
|
+
"SELECT #{core.set_quantifier ? 'DISTINCT DENSE_RANK()' : 'ROW_NUMBER()'} OVER (ORDER BY #{orders.map{ |x| visit(x) }.join(', ')}) AS [__rn],",
|
177
|
+
visit_Arel_Nodes_SelectStatementWithOutOffset(o,true),
|
178
|
+
") AS [__rnt]",
|
179
|
+
(visit(o.offset) if o.offset),
|
180
|
+
"ORDER BY [__rnt].[__rn] ASC"
|
181
|
+
].compact.join ' '
|
182
|
+
end
|
183
|
+
|
184
|
+
def visit_Arel_Nodes_SelectStatementForComplexCount(o)
|
185
|
+
core = o.cores.first
|
186
|
+
o.limit.expr = Arel.sql("#{o.limit.expr} + #{o.offset ? o.offset.expr : 0}") if o.limit
|
187
|
+
orders = rowtable_orders(o)
|
188
|
+
[ "SELECT COUNT([count]) AS [count_id]",
|
189
|
+
"FROM (",
|
190
|
+
"SELECT",
|
191
|
+
(visit(o.limit) if o.limit),
|
192
|
+
"ROW_NUMBER() OVER (ORDER BY #{orders.map{ |x| visit(x) }.join(', ')}) AS [__rn],",
|
193
|
+
"1 AS [count]",
|
194
|
+
(source_with_lock_for_select_statement(o)),
|
195
|
+
("WHERE #{core.wheres.map{ |x| visit(x) }.join ' AND ' }" unless core.wheres.empty?),
|
196
|
+
("GROUP BY #{core.groups.map { |x| visit x }.join ', ' }" unless core.groups.empty?),
|
197
|
+
(visit(core.having) if core.having),
|
198
|
+
("ORDER BY #{o.orders.map{ |x| visit(x) }.join(', ')}" if !o.orders.empty?),
|
199
|
+
") AS [__rnt]",
|
200
|
+
(visit(o.offset) if o.offset)
|
201
|
+
].compact.join ' '
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
# SQLServer Helpers
|
206
|
+
|
207
|
+
def source_with_lock_for_select_statement(o)
|
208
|
+
core = o.cores.first
|
209
|
+
source = "FROM #{visit(core.source).strip}" if core.source
|
210
|
+
if source && o.lock
|
211
|
+
lock = visit o.lock
|
212
|
+
index = source.match(/FROM [\w\[\]\.]+/)[0].mb_chars.length
|
213
|
+
source.insert index, " #{lock}"
|
214
|
+
else
|
215
|
+
source
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def table_from_select_statement(o)
|
220
|
+
core = o.cores.first
|
221
|
+
# TODO: [ARel 2.2] Use #from/#source vs. #froms
|
222
|
+
# if Arel::Table === core.from
|
223
|
+
# core.from
|
224
|
+
# elsif Arel::Nodes::SqlLiteral === core.from
|
225
|
+
# Arel::Table.new(core.from, @engine)
|
226
|
+
# elsif Arel::Nodes::JoinSource === core.source
|
227
|
+
# Arel::Nodes::SqlLiteral === core.source.left ? Arel::Table.new(core.source.left, @engine) : core.source.left
|
228
|
+
# end
|
229
|
+
table_finder = lambda { |x|
|
230
|
+
case x
|
231
|
+
when Arel::Table
|
232
|
+
x
|
233
|
+
when Arel::Nodes::SqlLiteral
|
234
|
+
Arel::Table.new(x, @engine)
|
235
|
+
when Arel::Nodes::Join
|
236
|
+
table_finder.call(x.left)
|
237
|
+
end
|
238
|
+
}
|
239
|
+
table_finder.call(core.froms)
|
240
|
+
end
|
241
|
+
|
242
|
+
def single_distinct_select_statement?(o)
|
243
|
+
projections = o.cores.first.projections
|
244
|
+
p1 = projections.first
|
245
|
+
projections.size == 1 &&
|
246
|
+
((p1.respond_to?(:distinct) && p1.distinct) ||
|
247
|
+
p1.respond_to?(:include?) && p1.include?('DISTINCT'))
|
248
|
+
end
|
249
|
+
|
250
|
+
def windowed_single_distinct_select_statement?(o)
|
251
|
+
o.limit && o.offset && single_distinct_select_statement?(o)
|
252
|
+
end
|
253
|
+
|
254
|
+
def single_distinct_select_everything_statement?(o)
|
255
|
+
single_distinct_select_statement?(o) && visit(o.cores.first.projections.first).ends_with?(".*")
|
256
|
+
end
|
257
|
+
|
258
|
+
def top_one_everything_for_through_join?(o)
|
259
|
+
single_distinct_select_everything_statement?(o) &&
|
260
|
+
(o.limit && !o.offset) &&
|
261
|
+
join_in_select_statement?(o)
|
262
|
+
end
|
263
|
+
|
264
|
+
def all_projections_aliased_in_select_statement?(o)
|
265
|
+
projections = o.cores.first.projections
|
266
|
+
projections.all? do |x|
|
267
|
+
visit(x).split(',').all? { |y| y.include?(' AS ') }
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def function_select_statement?(o)
|
272
|
+
core = o.cores.first
|
273
|
+
core.projections.any? { |x| Arel::Nodes::Function === x }
|
274
|
+
end
|
275
|
+
|
276
|
+
def eager_limiting_select_statement?(o)
|
277
|
+
core = o.cores.first
|
278
|
+
single_distinct_select_statement?(o) &&
|
279
|
+
(o.limit && !o.offset) &&
|
280
|
+
core.groups.empty? &&
|
281
|
+
!single_distinct_select_everything_statement?(o)
|
282
|
+
end
|
283
|
+
|
284
|
+
def join_in_select_statement?(o)
|
285
|
+
core = o.cores.first
|
286
|
+
core.source.right.any? { |x| Arel::Nodes::Join === x }
|
287
|
+
end
|
288
|
+
|
289
|
+
def complex_count_sql?(o)
|
290
|
+
core = o.cores.first
|
291
|
+
core.projections.size == 1 &&
|
292
|
+
Arel::Nodes::Count === core.projections.first &&
|
293
|
+
o.limit &&
|
294
|
+
!join_in_select_statement?(o)
|
295
|
+
end
|
296
|
+
|
297
|
+
def select_primary_key_sql?(o)
|
298
|
+
core = o.cores.first
|
299
|
+
return false if core.projections.size != 1
|
300
|
+
p = core.projections.first
|
301
|
+
t = table_from_select_statement(o)
|
302
|
+
Arel::Attributes::Attribute === p && t.primary_key && t.primary_key.name == p.name
|
303
|
+
end
|
304
|
+
|
305
|
+
def find_and_fix_uncorrelated_joins_in_select_statement(o)
|
306
|
+
core = o.cores.first
|
307
|
+
# TODO: [ARel 2.2] Use #from/#source vs. #froms
|
308
|
+
# return if !join_in_select_statement?(o) || core.source.right.size != 2
|
309
|
+
# j1 = core.source.right.first
|
310
|
+
# j2 = core.source.right.second
|
311
|
+
# return unless Arel::Nodes::OuterJoin === j1 && Arel::Nodes::StringJoin === j2
|
312
|
+
# j1_tn = j1.left.name
|
313
|
+
# j2_tn = j2.left.match(/JOIN \[(.*)\].*ON/).try(:[],1)
|
314
|
+
# return unless j1_tn == j2_tn
|
315
|
+
# crltd_tn = "#{j1_tn}_crltd"
|
316
|
+
# j1.left.table_alias = crltd_tn
|
317
|
+
# j1.right.expr.left.relation.table_alias = crltd_tn
|
318
|
+
return if !join_in_select_statement?(o) || !(Arel::Nodes::StringJoin === core.froms)
|
319
|
+
j1 = core.froms.left
|
320
|
+
j2 = core.froms.right
|
321
|
+
return unless Arel::Nodes::OuterJoin === j1 && Arel::Nodes::SqlLiteral === j2 && j2.include?('JOIN ')
|
322
|
+
j1_tn = j1.right.name
|
323
|
+
j2_tn = j2.match(/JOIN \[(.*)\].*ON/).try(:[],1)
|
324
|
+
return unless j1_tn == j2_tn
|
325
|
+
on_index = j2.index(' ON ')
|
326
|
+
j2.insert on_index, " AS [#{j2_tn}_crltd]"
|
327
|
+
j2.sub! "[#{j2_tn}].", "[#{j2_tn}_crltd]."
|
328
|
+
end
|
329
|
+
|
330
|
+
def rowtable_projections(o)
|
331
|
+
core = o.cores.first
|
332
|
+
if windowed_single_distinct_select_statement?(o) && core.groups.blank?
|
333
|
+
tn = table_from_select_statement(o).name
|
334
|
+
core.projections.map do |x|
|
335
|
+
x.dup.tap do |p|
|
336
|
+
p.sub! 'DISTINCT', ''
|
337
|
+
p.insert 0, visit(o.limit) if o.limit
|
338
|
+
p.gsub! /\[?#{tn}\]?\./, '[__rnt].'
|
339
|
+
p.strip!
|
340
|
+
end
|
341
|
+
end
|
342
|
+
elsif single_distinct_select_statement?(o)
|
343
|
+
tn = table_from_select_statement(o).name
|
344
|
+
core.projections.map do |x|
|
345
|
+
x.dup.tap do |p|
|
346
|
+
p.sub! 'DISTINCT', "DISTINCT #{visit(o.limit)}".strip if o.limit
|
347
|
+
p.gsub! /\[?#{tn}\]?\./, '[__rnt].'
|
348
|
+
p.strip!
|
349
|
+
end
|
350
|
+
end
|
351
|
+
elsif join_in_select_statement?(o) && all_projections_aliased_in_select_statement?(o)
|
352
|
+
core.projections.map do |x|
|
353
|
+
Arel.sql visit(x).split(',').map{ |y| y.split(' AS ').last.strip }.join(', ')
|
354
|
+
end
|
355
|
+
elsif select_primary_key_sql?(o)
|
356
|
+
[Arel.sql("[__rnt].#{quote_column_name(core.projections.first.name)}")]
|
357
|
+
else
|
358
|
+
[Arel.sql('[__rnt].*')]
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
def rowtable_orders(o)
|
363
|
+
core = o.cores.first
|
364
|
+
if !o.orders.empty?
|
365
|
+
o.orders
|
366
|
+
else
|
367
|
+
t = table_from_select_statement(o)
|
368
|
+
c = t.primary_key || t.columns.first
|
369
|
+
[c.asc]
|
370
|
+
end.uniq
|
371
|
+
end
|
372
|
+
|
373
|
+
# TODO: We use this for grouping too, maybe make Grouping objects vs SqlLiteral.
|
374
|
+
def projection_without_expression(projection)
|
375
|
+
Arel.sql(visit(projection).split(',').map do |x|
|
376
|
+
x.strip!
|
377
|
+
x.sub!(/^(COUNT|SUM|MAX|MIN|AVG)\s*(\((.*)\))?/,'\3')
|
378
|
+
x.sub!(/^DISTINCT\s*/,'')
|
379
|
+
x.sub!(/TOP\s*\(\d+\)\s*/i,'')
|
380
|
+
x.strip
|
381
|
+
end.join(', '))
|
382
|
+
end
|
383
|
+
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
end
|
388
|
+
|
389
|
+
Arel::Visitors::VISITORS['sqlserver'] = Arel::Visitors::SQLServer
|
metadata
CHANGED
@@ -1,14 +1,9 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-sqlserver-adapter
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 2
|
7
|
-
- 3
|
8
|
-
- 7
|
9
|
-
version: 2.3.7
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.2.18
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Ken Collins
|
13
8
|
- Murray Steele
|
14
9
|
- Shawn Balestracci
|
@@ -17,90 +12,72 @@ authors:
|
|
17
12
|
autorequire:
|
18
13
|
bindir: bin
|
19
14
|
cert_chain: []
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
date: 2017-06-19 00:00:00.000000000 Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: activerecord
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - "~>"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 3.2.0
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 3.2.0
|
31
|
+
description: ActiveRecord SQL Server Adapter. For SQL Server 2005 And Higher.
|
26
32
|
email: ken@metaskills.net
|
27
33
|
executables: []
|
28
|
-
|
29
34
|
extensions: []
|
30
|
-
|
31
|
-
|
32
|
-
- README.rdoc
|
33
|
-
files:
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
34
37
|
- CHANGELOG
|
35
38
|
- MIT-LICENSE
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
- lib/
|
39
|
+
- VERSION
|
40
|
+
- lib/active_record/connection_adapters/sqlserver/core_ext/active_record.rb
|
41
|
+
- lib/active_record/connection_adapters/sqlserver/core_ext/database_statements.rb
|
42
|
+
- lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb
|
43
|
+
- lib/active_record/connection_adapters/sqlserver/core_ext/explain_subscriber.rb
|
44
|
+
- lib/active_record/connection_adapters/sqlserver/core_ext/odbc.rb
|
45
|
+
- lib/active_record/connection_adapters/sqlserver/core_ext/relation.rb
|
46
|
+
- lib/active_record/connection_adapters/sqlserver/database_limits.rb
|
47
|
+
- lib/active_record/connection_adapters/sqlserver/database_statements.rb
|
48
|
+
- lib/active_record/connection_adapters/sqlserver/errors.rb
|
49
|
+
- lib/active_record/connection_adapters/sqlserver/quoting.rb
|
50
|
+
- lib/active_record/connection_adapters/sqlserver/schema_cache.rb
|
51
|
+
- lib/active_record/connection_adapters/sqlserver/schema_statements.rb
|
52
|
+
- lib/active_record/connection_adapters/sqlserver/showplan.rb
|
53
|
+
- lib/active_record/connection_adapters/sqlserver/showplan/printer_table.rb
|
54
|
+
- lib/active_record/connection_adapters/sqlserver/showplan/printer_xml.rb
|
55
|
+
- lib/active_record/connection_adapters/sqlserver/utils.rb
|
43
56
|
- lib/active_record/connection_adapters/sqlserver_adapter.rb
|
44
|
-
- lib/
|
45
|
-
- lib/
|
46
|
-
|
47
|
-
homepage: http://github.com/rails-sqlserver
|
57
|
+
- lib/activerecord-sqlserver-adapter.rb
|
58
|
+
- lib/arel/visitors/sqlserver.rb
|
59
|
+
homepage: http://github.com/rails-sqlserver/activerecord-sqlserver-adapter
|
48
60
|
licenses: []
|
49
|
-
|
61
|
+
metadata: {}
|
50
62
|
post_install_message:
|
51
|
-
rdoc_options:
|
52
|
-
|
53
|
-
- --inline-source
|
54
|
-
- --main
|
55
|
-
- README.rdoc
|
56
|
-
require_paths:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
57
65
|
- lib
|
58
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
60
68
|
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
67
73
|
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
- 0
|
71
|
-
version: "0"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
72
76
|
requirements: []
|
73
|
-
|
74
|
-
|
75
|
-
rubygems_version: 1.3.6
|
77
|
+
rubyforge_project: activerecord-sqlserver-adapter
|
78
|
+
rubygems_version: 2.6.8
|
76
79
|
signing_key:
|
77
|
-
specification_version:
|
78
|
-
summary: SQL Server
|
79
|
-
test_files:
|
80
|
-
|
81
|
-
- test/cases/adapter_test_sqlserver.rb
|
82
|
-
- test/cases/attribute_methods_test_sqlserver.rb
|
83
|
-
- test/cases/basics_test_sqlserver.rb
|
84
|
-
- test/cases/calculations_test_sqlserver.rb
|
85
|
-
- test/cases/column_test_sqlserver.rb
|
86
|
-
- test/cases/connection_test_sqlserver.rb
|
87
|
-
- test/cases/eager_association_test_sqlserver.rb
|
88
|
-
- test/cases/execute_procedure_test_sqlserver.rb
|
89
|
-
- test/cases/inheritance_test_sqlserver.rb
|
90
|
-
- test/cases/method_scoping_test_sqlserver.rb
|
91
|
-
- test/cases/migration_test_sqlserver.rb
|
92
|
-
- test/cases/named_scope_test_sqlserver.rb
|
93
|
-
- test/cases/offset_and_limit_test_sqlserver.rb
|
94
|
-
- test/cases/pessimistic_locking_test_sqlserver.rb
|
95
|
-
- test/cases/query_cache_test_sqlserver.rb
|
96
|
-
- test/cases/schema_dumper_test_sqlserver.rb
|
97
|
-
- test/cases/specific_schema_test_sqlserver.rb
|
98
|
-
- test/cases/sqlserver_helper.rb
|
99
|
-
- test/cases/table_name_test_sqlserver.rb
|
100
|
-
- test/cases/transaction_test_sqlserver.rb
|
101
|
-
- test/cases/unicode_test_sqlserver.rb
|
102
|
-
- test/cases/validations_test_sqlserver.rb
|
103
|
-
- test/connections/native_sqlserver/connection.rb
|
104
|
-
- test/connections/native_sqlserver_odbc/connection.rb
|
105
|
-
- test/migrations/transaction_table/1_table_will_never_be_created.rb
|
106
|
-
- test/schema/sqlserver_specific_schema.rb
|
80
|
+
specification_version: 4
|
81
|
+
summary: ActiveRecord SQL Server Adapter. For SQL Server 2005 And Higher.
|
82
|
+
test_files: []
|
83
|
+
has_rdoc:
|