activerecord-sqlserver-adapter 4.2.0 → 4.2.1

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: 0aee2e7463020662106644d64594b1cd857559fe
4
- data.tar.gz: 193864928eb15fb868cdbd49bc1754ae7f915d6a
3
+ metadata.gz: dc44e3b9473a3d9c9070b2ca07d12086a2671a6b
4
+ data.tar.gz: d0c038b489868dacf097104d08dd9e0e23d68f56
5
5
  SHA512:
6
- metadata.gz: f2f572dbcb8931c53cff675a3aaf45f4da18b3c61eeeb36138a726a8e40f2d1e40497ed524bf5cc60b94640070583d1fb2a706ec7b6e5cb19877e7208367ca0e
7
- data.tar.gz: 597b940c01ecba50345383606c622cfa6a60ae8ac37a376b034c7cf6a1d16603533fe64a2caa0e5d2b2349ea65978c2283a058371e95fe50bee10a4ef0cef247
6
+ metadata.gz: e744bbfbe647d84ea95e787759d46a5df02b1357b6212d720cdb5c52aaae0edcefc6e15c7f76da19c0014cbda645702b161e786ee17d7be995aae08eb0bc0a87
7
+ data.tar.gz: b65102d0b2f4deee4732d3718e82c8763d8e729dd40ac6f05ee8c8ed7b1fd8a740f9da02f03978f7171ce289b0fd3546a3c0c51537bee5010ff6a71e225b7f58
@@ -1,4 +1,13 @@
1
1
 
2
+ ## v4.2.1
3
+
4
+ #### Fixed
5
+
6
+ * Guard against empty view definitions when `sb_helptext` fails silently. Fixes #337.
7
+ * Proper table/column escaping in the `change_column_null` method. Fixes #355.
8
+ * Use `send :include` for modules for 1.9 compatibility. Fixes #383.
9
+
10
+
2
11
  ## v4.2.0
3
12
 
4
13
  #### Added
data/README.md CHANGED
@@ -10,12 +10,6 @@
10
10
 
11
11
  The SQL Server adapter for ActiveRecord. If you need the adapter for SQL Server 2008 or 2005, you are still in the right spot. Just install the latest 3.2.x to 4.1.x version of the adapter. We follow a rational versioning policy that tracks ActiveRecord. That means that our 4.2.x version of the adapter is only for the latest 4.2 version of Rails. We also have stable branches for each major/minor release of ActiveRecord.
12
12
 
13
- The 4.2 gem is in pre-release till we get a few more [bugs](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/milestones) worked out. Bundle to the pre version or this repos master directory.
14
-
15
- ```ruby
16
- gem 'activerecord-sqlserver-adapter', '~> 4.2.0.pre'
17
- ```
18
-
19
13
 
20
14
  #### Testing Rake Tasks Support
21
15
 
@@ -17,6 +17,16 @@ Default testing uses DBLIB with TinyTDS.
17
17
  * $ bundle install
18
18
  * $ bundle exec rake test ACTIVERECORD_UNITTEST_HOST='my.db.net'
19
19
 
20
+ Focusing tests. Use the `ONLY_` env vars to run either ours or the ActiveRecord cases. Use the `TEST_FILES` env variants to focus on specific test(s), use commas for multiple cases. Note, you have to use different env vars to focus only on ours or a core ActiveRecord case. There may be failures when focusing on an ActiveRecord case since our coereced test files is not loaded in this scenerio.
21
+
22
+ ```
23
+ $ bundle exec rake test ONLY_SQLSERVER=1
24
+ $ bundle exec rake test ONLY_ACTIVERECORD=1
25
+
26
+ $ bundle exec rake test TEST_FILES="test/cases/adapter_test_sqlserver.rb"
27
+ $ bundle exec rake test TEST_FILES_AR="test/cases/finder_test.rb"
28
+ ```
29
+
20
30
 
21
31
  ## Creating the test databases
22
32
 
@@ -166,11 +166,13 @@ module ActiveRecord
166
166
  end
167
167
 
168
168
  def change_column_null(table_name, column_name, allow_null, default = nil)
169
+ table_id = SQLServer::Utils.extract_identifiers(table_name)
170
+ column_id = SQLServer::Utils.extract_identifiers(column_name)
169
171
  column = detect_column_for! table_name, column_name
170
172
  if !allow_null.nil? && allow_null == false && !default.nil?
171
- do_execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL")
173
+ do_execute("UPDATE #{table_id} SET #{column_id}=#{quote(default)} WHERE #{column_id} IS NULL")
172
174
  end
173
- sql = "ALTER TABLE #{table_name} ALTER COLUMN #{quote_column_name(column_name)} #{type_to_sql column.type, column.limit, column.precision, column.scale}"
175
+ sql = "ALTER TABLE #{table_id} ALTER COLUMN #{column_id} #{type_to_sql column.type, column.limit, column.precision, column.scale}"
174
176
  sql << ' NOT NULL' if !allow_null.nil? && allow_null == false
175
177
  do_execute sql
176
178
  end
@@ -415,6 +417,7 @@ module ActiveRecord
415
417
 
416
418
  def views_real_column_name(table_name, column_name)
417
419
  view_definition = schema_cache.view_information(table_name)[:VIEW_DEFINITION]
420
+ return column_name unless view_definition
418
421
  match_data = view_definition.match(/([\w-]*)\s+as\s+#{column_name}/im)
419
422
  match_data ? match_data[1] : column_name
420
423
  end
@@ -19,7 +19,7 @@ module ActiveRecord
19
19
 
20
20
  end
21
21
 
22
- Transaction.include SQLServerTransaction
22
+ Transaction.send :include, SQLServerTransaction
23
23
 
24
24
  module SQLServerRealTransaction
25
25
 
@@ -46,7 +46,7 @@ module ActiveRecord
46
46
 
47
47
  end
48
48
 
49
- RealTransaction.include SQLServerRealTransaction
49
+ RealTransaction.send :include, SQLServerRealTransaction
50
50
 
51
51
  end
52
52
  end
@@ -3,7 +3,7 @@ module ActiveRecord
3
3
  module SQLServer
4
4
  module Version
5
5
 
6
- VERSION = '4.2.0'
6
+ VERSION = '4.2.1'
7
7
 
8
8
  end
9
9
  end
@@ -18,13 +18,5 @@ module ActiveRecord
18
18
  ConnectionAdapters::SQLServerAdapter.new(nil, logger, nil, config.merge(mode: mode))
19
19
  end
20
20
 
21
- def self.did_retry_sqlserver_connection(connection, count)
22
- logger.info "CONNECTION RETRY: #{connection.class.name} retry ##{count}."
23
- end
24
-
25
- def self.did_lose_sqlserver_connection(connection)
26
- logger.info "CONNECTION LOST: #{connection.class.name}"
27
- end
28
-
29
21
  end
30
22
  end
@@ -109,72 +109,6 @@ class ConnectionTestSQLServer < ActiveRecord::TestCase
109
109
  assert connection.active?
110
110
  end
111
111
 
112
- describe 'with a deadlock victim exception 1205' do
113
-
114
- describe 'outside a transaction' do
115
-
116
- before do
117
- @query = "SELECT 1 as [one]"
118
- @expected = connection.execute(@query)
119
- # Execute the query to get a handle of the expected result, which
120
- # will be returned after a simulated deadlock victim (1205).
121
- raw_conn = connection.raw_connection
122
- stubbed_handle = raw_conn.execute(@query)
123
- connection.send(:finish_statement_handle, stubbed_handle)
124
- raw_conn.stubs(:execute).raises(deadlock_victim_exception(@query)).then.returns(stubbed_handle)
125
- end
126
-
127
- it 'raise ActiveRecord::DeadlockVictim' do
128
- assert_raise(ActiveRecord::DeadlockVictim) do
129
- assert_equal @expected, connection.execute(@query)
130
- end
131
- end
132
-
133
- end
134
-
135
- describe 'within a transaction' do
136
-
137
- before do
138
- @query = "SELECT 1 as [one]"
139
- @expected = connection.execute(@query)
140
- # We "stub" the execute method to simulate raising a deadlock victim exception once.
141
- connection.class.class_eval do
142
- def execute_with_deadlock_exception(sql, *args)
143
- if !@raised_deadlock_exception && sql == "SELECT 1 as [one]"
144
- sql = "RAISERROR('Transaction (Process ID #{Process.pid}) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.: #{sql}', 13, 1)"
145
- @raised_deadlock_exception = true
146
- elsif @raised_deadlock_exception == true && sql =~ /RAISERROR\('Transaction \(Process ID \d+\) was deadlocked on lock resources with another process and has been chosen as the deadlock victim\. Rerun the transaction\.: SELECT 1 as \[one\]', 13, 1\)/
147
- sql = "SELECT 1 as [one]"
148
- end
149
- execute_without_deadlock_exception(sql, *args)
150
- end
151
- alias :execute_without_deadlock_exception :execute
152
- alias :execute :execute_with_deadlock_exception
153
- end
154
- end
155
-
156
- after do
157
- # Cleanup the "stubbed" execute method.
158
- connection.class.class_eval do
159
- alias :execute :execute_without_deadlock_exception
160
- remove_method :execute_with_deadlock_exception
161
- remove_method :execute_without_deadlock_exception
162
- end
163
- connection.send(:remove_instance_variable, :@raised_deadlock_exception)
164
- end
165
-
166
- it 'raise ActiveRecord::DeadlockVictim if retry disabled' do
167
- assert_raise(ActiveRecord::DeadlockVictim) do
168
- ActiveRecord::Base.transaction do
169
- assert_equal @expected, connection.execute(@query)
170
- end
171
- end
172
- end
173
-
174
- end
175
-
176
- end if connection_mode_dblib? # Since it is easier to test, but feature should work in ODBC too.
177
-
178
112
  end
179
113
 
180
114
 
@@ -205,12 +139,4 @@ class ConnectionTestSQLServer < ActiveRecord::TestCase
205
139
  GC.enable
206
140
  end
207
141
 
208
- def deadlock_victim_exception(sql)
209
- require 'tiny_tds/error'
210
- error = TinyTds::Error.new("Transaction (Process ID #{Process.pid}) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.: #{sql}")
211
- error.severity = 13
212
- error.db_error_number = 1205
213
- error
214
- end
215
-
216
142
  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: 4.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins