activerecord-sqlserver-adapter 3.2.16 → 3.2.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 726e72febb5f0fd2fecfb88581b92e6af50daac9
4
- data.tar.gz: d2feeaa8cf3353c3551f4785fcb1f1e4006ef851
3
+ metadata.gz: 635da017102e0833bf95d12a189ec49b0f33b750
4
+ data.tar.gz: b2c4a918c2f8f2636416ae78c514599fd34987f9
5
5
  SHA512:
6
- metadata.gz: 1091df35f40b10a76aeda89647cea24196822a14a2f730f6741c73a499bb77aac4dd1eea94b1cdeca20e25f0948d54efe94ca4e7ac044ba649081309b321d4cc
7
- data.tar.gz: 1e7e1738c77ad41a15f0bbd298c99c3dbc1d69c037973e04a9b5e63ab48f3c9becc1336c701553cf9ad8a511c0b21c3e3ccd4d79d2cde91d30bdac07f20bca93
6
+ metadata.gz: 1d911a8d3d9fc475a9e323b1955f80f16d436456c60dff4f72c9c46e4ddf32819f07ff875e32c59ac3e6a0ebb7f7a8b5945d2aa5294e4e6a0eee6d667466b091
7
+ data.tar.gz: f1813fe974324a2879d827e3db53565849a73104e2266541b9a281acbc4eef9da16fe574eb58d29029a83a5492eea1154b587c8f6167a24f0bf19c35dcce4ae1
data/CHANGELOG CHANGED
@@ -1,7 +1,13 @@
1
+ * 3.2.17*
2
+
3
+ * Add `WITH NO_INFOMSGS` to `user_options` method. Fixes #580
4
+
5
+
1
6
  * 3.2.16 *
2
7
 
3
8
  * All user optons to be array/hash. Fixes #540
4
9
 
10
+
5
11
  * 3.2.15 *
6
12
 
7
13
  * Added vNext support.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.16
1
+ 3.2.17
@@ -2,9 +2,9 @@ module ActiveRecord
2
2
  module ConnectionAdapters
3
3
  module Sqlserver
4
4
  module DatabaseStatements
5
-
5
+
6
6
  include CoreExt::DatabaseStatements
7
-
7
+
8
8
  def select_rows(sql, name = nil)
9
9
  raw_select sql, name, [], :fetch => :rows
10
10
  end
@@ -16,7 +16,7 @@ module ActiveRecord
16
16
  do_execute(sql,name)
17
17
  end
18
18
  end
19
-
19
+
20
20
  def exec_query(sql, name = 'SQL', binds = [], sqlserver_options = {})
21
21
  if id_insert_table_name = sqlserver_options[:insert] ? query_requires_identity_insert?(sql) : nil
22
22
  with_identity_insert_enabled(id_insert_table_name) { do_exec_query(sql, name, binds) }
@@ -24,11 +24,11 @@ module ActiveRecord
24
24
  do_exec_query(sql, name, binds)
25
25
  end
26
26
  end
27
-
27
+
28
28
  def exec_insert(sql, name, binds)
29
29
  exec_query sql, name, binds, :insert => true
30
30
  end
31
-
31
+
32
32
  def exec_delete(sql, name, binds)
33
33
  sql << "; SELECT @@ROWCOUNT AS AffectedRows"
34
34
  super.rows.first.first
@@ -42,7 +42,7 @@ module ActiveRecord
42
42
  def outside_transaction?
43
43
  uncached { select_value('SELECT @@TRANCOUNT', 'SCHEMA') == 0 }
44
44
  end
45
-
45
+
46
46
  def supports_statement_cache?
47
47
  true
48
48
  end
@@ -89,9 +89,9 @@ module ActiveRecord
89
89
  def case_sensitive_modifier(node)
90
90
  node.acts_like?(:string) ? Arel::Nodes::Bin.new(node) : node
91
91
  end
92
-
92
+
93
93
  # === SQLServer Specific ======================================== #
94
-
94
+
95
95
  def execute_procedure(proc_name, *variables)
96
96
  vars = if variables.any? && variables.first.is_a?(Hash)
97
97
  variables.first.map { |k,v| "@#{k} = #{quote(v)}" }
@@ -126,17 +126,17 @@ module ActiveRecord
126
126
  end
127
127
  end
128
128
  end
129
-
129
+
130
130
  def use_database(database=nil)
131
131
  return if sqlserver_azure?
132
132
  database ||= @connection_options[:database]
133
133
  do_execute "USE #{quote_table_name(database)}" unless database.blank?
134
134
  end
135
-
135
+
136
136
  def user_options
137
137
  return {} if sqlserver_azure?
138
138
  # fixes #535
139
- rows = select_rows('dbcc useroptions', 'SCHEMA')
139
+ rows = select_rows('DBCC USEROPTIONS WITH NO_INFOMSGS', 'SCHEMA')
140
140
  rows = rows.first if rows.size == 2 && rows.last.empty?
141
141
  rows.reduce(HashWithIndifferentAccess.new) do |values, row|
142
142
  if row.instance_of? Hash
@@ -150,7 +150,7 @@ module ActiveRecord
150
150
  values
151
151
  end
152
152
  end
153
-
153
+
154
154
  def user_options_dateformat
155
155
  if sqlserver_azure?
156
156
  select_value 'SELECT [dateformat] FROM [sys].[syslanguages] WHERE [langid] = @@LANGID', 'SCHEMA'
@@ -158,24 +158,24 @@ module ActiveRecord
158
158
  user_options['dateformat']
159
159
  end
160
160
  end
161
-
161
+
162
162
  def user_options_isolation_level
163
163
  if sqlserver_azure?
164
- sql = %|SELECT CASE [transaction_isolation_level]
164
+ sql = %|SELECT CASE [transaction_isolation_level]
165
165
  WHEN 0 THEN NULL
166
- WHEN 1 THEN 'READ UNCOMITTED'
167
- WHEN 2 THEN 'READ COMITTED'
168
- WHEN 3 THEN 'REPEATABLE READ'
169
- WHEN 4 THEN 'SERIALIZABLE'
170
- WHEN 5 THEN 'SNAPSHOT' END AS [isolation_level]
171
- FROM [sys].[dm_exec_sessions]
166
+ WHEN 1 THEN 'READ UNCOMITTED'
167
+ WHEN 2 THEN 'READ COMITTED'
168
+ WHEN 3 THEN 'REPEATABLE READ'
169
+ WHEN 4 THEN 'SERIALIZABLE'
170
+ WHEN 5 THEN 'SNAPSHOT' END AS [isolation_level]
171
+ FROM [sys].[dm_exec_sessions]
172
172
  WHERE [session_id] = @@SPID|.squish
173
173
  select_value sql, 'SCHEMA'
174
174
  else
175
175
  user_options['isolation_level']
176
176
  end
177
177
  end
178
-
178
+
179
179
  def user_options_language
180
180
  if sqlserver_azure?
181
181
  select_value 'SELECT @@LANGUAGE AS [language]', 'SCHEMA'
@@ -189,20 +189,20 @@ module ActiveRecord
189
189
  initial_isolation_level = user_options_isolation_level || "READ COMMITTED"
190
190
  do_execute "SET TRANSACTION ISOLATION LEVEL #{isolation_level}"
191
191
  begin
192
- yield
192
+ yield
193
193
  ensure
194
194
  do_execute "SET TRANSACTION ISOLATION LEVEL #{initial_isolation_level}"
195
195
  end if block_given?
196
196
  end
197
-
197
+
198
198
  def newid_function
199
199
  select_value "SELECT NEWID()"
200
200
  end
201
-
201
+
202
202
  def newsequentialid_function
203
203
  select_value "SELECT NEWSEQUENTIALID()"
204
204
  end
205
-
205
+
206
206
  def activity_stats
207
207
  select_all %|
208
208
  SELECT
@@ -247,9 +247,9 @@ module ActiveRecord
247
247
  WHERE db_name(r.database_id) = '#{current_database}'
248
248
  ORDER BY s.session_id|
249
249
  end
250
-
250
+
251
251
  # === SQLServer Specific (Rake/Test Helpers) ==================== #
252
-
252
+
253
253
  def recreate_database
254
254
  remove_database_connections_and_rollback do
255
255
  do_execute "EXEC sp_MSforeachtable 'DROP TABLE ?'"
@@ -293,18 +293,18 @@ module ActiveRecord
293
293
  def current_database
294
294
  select_value 'SELECT DB_NAME()'
295
295
  end
296
-
296
+
297
297
  def charset
298
298
  select_value "SELECT SERVERPROPERTY('SqlCharSetName')"
299
299
  end
300
-
301
-
300
+
301
+
302
302
  protected
303
-
303
+
304
304
  def select(sql, name = nil, binds = [])
305
305
  exec_query(sql, name, binds).to_a
306
306
  end
307
-
307
+
308
308
  def sql_for_insert(sql, pk, id_value, sequence_name, binds)
309
309
  sql = "#{sql}; SELECT CAST(SCOPE_IDENTITY() AS bigint) AS Ident"# unless binds.empty?
310
310
  super
@@ -313,13 +313,13 @@ module ActiveRecord
313
313
  def last_inserted_id(result)
314
314
  super || select_value("SELECT CAST(SCOPE_IDENTITY() AS bigint) AS Ident")
315
315
  end
316
-
316
+
317
317
  # === SQLServer Specific ======================================== #
318
-
318
+
319
319
  def valid_isolation_levels
320
320
  ["READ COMMITTED", "READ UNCOMMITTED", "REPEATABLE READ", "SERIALIZABLE", "SNAPSHOT"]
321
321
  end
322
-
322
+
323
323
  # === SQLServer Specific (Executing) ============================ #
324
324
 
325
325
  def do_execute(sql, name = 'SQL')
@@ -327,7 +327,7 @@ module ActiveRecord
327
327
  with_sqlserver_error_handling { raw_connection_do(sql) }
328
328
  end
329
329
  end
330
-
330
+
331
331
  def do_exec_query(sql, name, binds)
332
332
  explaining = name == 'EXPLAIN'
333
333
  names_and_types = []
@@ -361,7 +361,7 @@ module ActiveRecord
361
361
  end
362
362
  raw_select sql, name, binds, :ar_result => true
363
363
  end
364
-
364
+
365
365
  def raw_connection_do(sql)
366
366
  case @connection_options[:mode]
367
367
  when :dblib
@@ -372,13 +372,13 @@ module ActiveRecord
372
372
  ensure
373
373
  @update_sql = false
374
374
  end
375
-
375
+
376
376
  # === SQLServer Specific (Selecting) ============================ #
377
377
 
378
378
  def raw_select(sql, name='SQL', binds=[], options={})
379
379
  log(sql,name,binds) { _raw_select(sql, options) }
380
380
  end
381
-
381
+
382
382
  def _raw_select(sql, options={})
383
383
  begin
384
384
  handle = raw_connection_run(sql)
@@ -387,7 +387,7 @@ module ActiveRecord
387
387
  finish_statement_handle(handle)
388
388
  end
389
389
  end
390
-
390
+
391
391
  def raw_connection_run(sql)
392
392
  with_sqlserver_error_handling do
393
393
  case @connection_options[:mode]
@@ -398,7 +398,7 @@ module ActiveRecord
398
398
  end
399
399
  end
400
400
  end
401
-
401
+
402
402
  def handle_more_results?(handle)
403
403
  case @connection_options[:mode]
404
404
  when :dblib
@@ -406,7 +406,7 @@ module ActiveRecord
406
406
  handle.more_results
407
407
  end
408
408
  end
409
-
409
+
410
410
  def handle_to_names_and_values(handle, options={})
411
411
  case @connection_options[:mode]
412
412
  when :dblib
@@ -415,7 +415,7 @@ module ActiveRecord
415
415
  handle_to_names_and_values_odbc(handle, options)
416
416
  end
417
417
  end
418
-
418
+
419
419
  def handle_to_names_and_values_dblib(handle, options={})
420
420
  query_options = {}.tap do |qo|
421
421
  qo[:timezone] = ActiveRecord::Base.default_timezone || :utc
@@ -425,7 +425,7 @@ module ActiveRecord
425
425
  columns = lowercase_schema_reflection ? handle.fields.map { |c| c.downcase } : handle.fields
426
426
  options[:ar_result] ? ActiveRecord::Result.new(columns, results) : results
427
427
  end
428
-
428
+
429
429
  def handle_to_names_and_values_odbc(handle, options={})
430
430
  @connection.use_utc = ActiveRecord::Base.default_timezone == :utc
431
431
  if options[:ar_result]
@@ -441,7 +441,7 @@ module ActiveRecord
441
441
  end
442
442
  end
443
443
  end
444
-
444
+
445
445
  def finish_statement_handle(handle)
446
446
  case @connection_options[:mode]
447
447
  when :dblib
@@ -451,7 +451,7 @@ module ActiveRecord
451
451
  end
452
452
  handle
453
453
  end
454
-
454
+
455
455
  end
456
456
  end
457
457
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-sqlserver-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.16
4
+ version: 3.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-01-31 00:00:00.000000000 Z
15
+ date: 2017-03-26 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project: activerecord-sqlserver-adapter
78
- rubygems_version: 2.6.4
78
+ rubygems_version: 2.6.8
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: ActiveRecord SQL Server Adapter. For SQL Server 2005 And Higher.