activerecord-sqlserver-adapter 3.1.2 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
|
2
|
+
* 3.1.3 *
|
3
|
+
|
4
|
+
* Distinguish between identity and primary key key columns during schema reflection. Allows us
|
5
|
+
us to only do identity inserts when technically needed. Fixes #139 [chadcf] & [joncanady]
|
6
|
+
|
7
|
+
|
2
8
|
* 3.1.2 *
|
3
9
|
|
4
10
|
* Fix SQL Azure conflicts with DBCC useroptions. Use new #user_options_xyz methods. [kazamachi]
|
@@ -194,6 +194,9 @@ module ActiveRecord
|
|
194
194
|
END AS [is_nullable],
|
195
195
|
CASE
|
196
196
|
WHEN CCU.COLUMN_NAME IS NOT NULL AND TC.CONSTRAINT_TYPE = N'PRIMARY KEY' THEN 1
|
197
|
+
ELSE NULL
|
198
|
+
END AS [is_primary],
|
199
|
+
CASE
|
197
200
|
WHEN COLUMNPROPERTY(OBJECT_ID(columns.TABLE_SCHEMA+'.'+columns.TABLE_NAME), columns.COLUMN_NAME, 'IsIdentity') = 1 THEN 1
|
198
201
|
ELSE NULL
|
199
202
|
END AS [is_identity]
|
@@ -239,6 +242,7 @@ module ActiveRecord
|
|
239
242
|
match_data ? match_data[1] : nil
|
240
243
|
end
|
241
244
|
ci[:null] = ci[:is_nullable].to_i == 1 ; ci.delete(:is_nullable)
|
245
|
+
ci[:is_primary] = ci[:is_primary].to_i == 1
|
242
246
|
ci[:is_identity] = ci[:is_identity].to_i == 1
|
243
247
|
ci
|
244
248
|
end
|
@@ -363,7 +367,7 @@ module ActiveRecord
|
|
363
367
|
if insert_sql?(sql)
|
364
368
|
table_name = get_table_name(sql)
|
365
369
|
id_column = identity_column(table_name)
|
366
|
-
id_column &&
|
370
|
+
id_column && sql =~ /^\s*(INSERT|EXEC sp_executesql N'INSERT)[^(]+\([^)]*\b(#{id_column.name})\b,?[^)]*\)/i ? quote_table_name(table_name) : false
|
367
371
|
else
|
368
372
|
false
|
369
373
|
end
|
@@ -389,7 +393,7 @@ module ActiveRecord
|
|
389
393
|
end
|
390
394
|
|
391
395
|
def identity_column(table_name)
|
392
|
-
columns(table_name).detect(&:
|
396
|
+
columns(table_name).detect(&:is_identity?)
|
393
397
|
end
|
394
398
|
|
395
399
|
end
|
@@ -53,7 +53,7 @@ module ActiveRecord
|
|
53
53
|
def initialize(name, default, sql_type = nil, null = true, sqlserver_options = {})
|
54
54
|
@sqlserver_options = sqlserver_options.symbolize_keys
|
55
55
|
super(name, default, sql_type, null)
|
56
|
-
@primary = @sqlserver_options[:is_identity]
|
56
|
+
@primary = @sqlserver_options[:is_identity] || @sqlserver_options[:is_primary]
|
57
57
|
end
|
58
58
|
|
59
59
|
class << self
|
@@ -72,6 +72,10 @@ module ActiveRecord
|
|
72
72
|
@sqlserver_options[:is_identity]
|
73
73
|
end
|
74
74
|
|
75
|
+
def is_primary?
|
76
|
+
@sqlserver_options[:is_primary]
|
77
|
+
end
|
78
|
+
|
75
79
|
def is_utf8?
|
76
80
|
!!(@sql_type =~ /nvarchar|ntext|nchar/i)
|
77
81
|
end
|
@@ -289,7 +293,7 @@ module ActiveRecord
|
|
289
293
|
end
|
290
294
|
|
291
295
|
def primary_key(table_name)
|
292
|
-
identity_column(table_name).try(:name)
|
296
|
+
identity_column(table_name).try(:name) || columns(table_name).detect(&:is_primary?).try(:name)
|
293
297
|
end
|
294
298
|
|
295
299
|
# === SQLServer Specific (DB Reflection) ======================== #
|
@@ -434,8 +438,8 @@ module ActiveRecord
|
|
434
438
|
|
435
439
|
# Override this method so every connection can be configured to your needs.
|
436
440
|
# For example:
|
437
|
-
#
|
438
|
-
#
|
441
|
+
# raw_connection_do "SET TEXTSIZE #{64.megabytes}"
|
442
|
+
# raw_connection_do "SET CONCAT_NULL_YIELDS_NULL ON"
|
439
443
|
def configure_connection
|
440
444
|
end
|
441
445
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-sqlserver-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 3.1.
|
9
|
+
- 3
|
10
|
+
version: 3.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ken Collins
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2011-10-
|
22
|
+
date: 2011-10-28 00:00:00 -04:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|