activerecord-sqlserver-adapter 2.3.3 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,6 +1,19 @@
1
1
 
2
2
  MASTER
3
3
 
4
+
5
+ * 2.3.4
6
+
7
+ * For tables that named with schema(ex. rails.users), they could not get length of column.
8
+ column of varchar(40) gets length => nil. Ticket #27 & #15 [Ken Tachiya]
9
+
10
+ * Altered limited_update_conditions regex conditions, the .* would greedily fail
11
+ if the where_sql had WHERE in a table or field, etc. [Ransom Briggs]
12
+
13
+ * Changing test to allow ENV['ARUNIT_DB_NAME'] as the database name for the test units.
14
+ Matches up with AR conventions. [Ransom Briggs]
15
+
16
+
4
17
  2.3.3
5
18
 
6
19
  * Revert #ad83df82 and again cache column information at the connection's instance. The
@@ -159,7 +159,7 @@ module ActiveRecord
159
159
  class SQLServerAdapter < AbstractAdapter
160
160
 
161
161
  ADAPTER_NAME = 'SQLServer'.freeze
162
- VERSION = '2.3.3'.freeze
162
+ VERSION = '2.3.4'.freeze
163
163
  DATABASE_VERSION_REGEXP = /Microsoft SQL Server\s+(\d{4})/
164
164
  SUPPORTED_VERSIONS = [2000,2005,2008].freeze
165
165
  LIMITABLE_TYPES = ['string','integer','float','char','nchar','varchar','nvarchar'].freeze
@@ -522,7 +522,7 @@ module ActiveRecord
522
522
  end
523
523
 
524
524
  def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key)
525
- match_data = where_sql.match(/(.*)WHERE/)
525
+ match_data = where_sql.match(/^(.*?[\]\) ])WHERE[\[\( ]/)
526
526
  limit = match_data[1]
527
527
  where_sql.sub!(limit,'')
528
528
  "WHERE #{quoted_primary_key} IN (SELECT #{limit} #{quoted_primary_key} FROM #{quoted_table_name} #{where_sql})"
@@ -1042,7 +1042,7 @@ module ActiveRecord
1042
1042
  columns.NUMERIC_PRECISION as numeric_precision,
1043
1043
  CASE
1044
1044
  WHEN columns.DATA_TYPE IN ('nchar','nvarchar') THEN columns.CHARACTER_MAXIMUM_LENGTH
1045
- ELSE COL_LENGTH(columns.TABLE_NAME, columns.COLUMN_NAME)
1045
+ ELSE COL_LENGTH(columns.TABLE_SCHEMA+'.'+columns.TABLE_NAME, columns.COLUMN_NAME)
1046
1046
  END as length,
1047
1047
  CASE
1048
1048
  WHEN columns.IS_NULLABLE = 'YES' THEN 1
@@ -128,6 +128,15 @@ class AdapterTestSqlserver < ActiveRecord::TestCase
128
128
  assert !@connection.send(:insert_sql?,'UPDATE...')
129
129
  assert !@connection.send(:insert_sql?,'SELECT...')
130
130
  end
131
+
132
+ context 'for #limited_update_conditions' do
133
+
134
+ should 'only match up to the first WHERE' do
135
+ where_sql = "TOP 1 WHERE ([posts].author_id = 1 and [posts].columnWHEREname = 2) ORDER BY posts.id"
136
+ assert_equal "WHERE bar IN (SELECT TOP 1 bar FROM foo WHERE ([posts].author_id = 1 and [posts].columnWHEREname = 2) ORDER BY posts.id)", @connection.limited_update_conditions(where_sql, 'foo', 'bar')
137
+ end
138
+
139
+ end
131
140
 
132
141
  context 'for #sql_for_association_limiting?' do
133
142
 
@@ -16,7 +16,7 @@ class ExecuteProcedureTestSqlserver < ActiveRecord::TestCase
16
16
  tables = @klass.execute_procedure :sp_tables, 'sql_server_chronics'
17
17
  table_info = tables.first
18
18
  assert_equal 1, tables.size
19
- assert_equal 'activerecord_unittest', table_info[:TABLE_QUALIFIER], "Table Info: #{table_info.inspect}"
19
+ assert_equal (ENV['ARUNIT_DB_NAME'] || 'activerecord_unittest'), table_info[:TABLE_QUALIFIER], "Table Info: #{table_info.inspect}"
20
20
  assert_equal 'TABLE', table_info[:TABLE_TYPE], "Table Info: #{table_info.inspect}"
21
21
  end
22
22
 
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: 2.3.3
4
+ version: 2.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-02-15 00:00:00 -05:00
16
+ date: 2010-02-17 00:00:00 -05:00
17
17
  default_executable:
18
18
  dependencies: []
19
19