activerecord-sqlserver-adapter 4.2.5 → 4.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +9 -9
- data/lib/active_record/connection_adapters/sqlserver/utils.rb +4 -0
- data/lib/active_record/connection_adapters/sqlserver/version.rb +1 -1
- data/test/cases/utils_test_sqlserver.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e84d27ebd75f08bcf37cf9243972440b0fc57280
|
4
|
+
data.tar.gz: f1f0a3e19713a80cdeba715025b4cb8523574c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f35f9ee3b2b34f7601f86d6867f2a86bf618203411e6e94ba4eec6b8d92f26cca09c63ae0596f50acacd4090fc644c4bfba43a3d2b7f2c33f849b170174d3cad
|
7
|
+
data.tar.gz: e59869fcb2a59c6a68a3778a56f7a1834becaec3c15844b44ed522115ca1a157cffe18c378b48cb697904188580171cdca76940f800377228c030ebc00c57233
|
data/CHANGELOG.md
CHANGED
@@ -221,7 +221,7 @@ module ActiveRecord
|
|
221
221
|
|
222
222
|
def column_definitions(table_name)
|
223
223
|
identifier = SQLServer::Utils.extract_identifiers(table_name)
|
224
|
-
database =
|
224
|
+
database = identifier.fully_qualified_database_quoted
|
225
225
|
view_exists = schema_cache.view_exists?(table_name)
|
226
226
|
view_tblnm = table_name_or_views_table_name(table_name) if view_exists
|
227
227
|
sql = %{
|
@@ -237,7 +237,7 @@ module ActiveRecord
|
|
237
237
|
columns.ordinal_position,
|
238
238
|
CASE
|
239
239
|
WHEN columns.DATA_TYPE IN ('nchar','nvarchar','char','varchar') THEN columns.CHARACTER_MAXIMUM_LENGTH
|
240
|
-
ELSE COL_LENGTH('#{database}'+columns.TABLE_SCHEMA+'.'+columns.TABLE_NAME, columns.COLUMN_NAME)
|
240
|
+
ELSE COL_LENGTH('#{database}.'+columns.TABLE_SCHEMA+'.'+columns.TABLE_NAME, columns.COLUMN_NAME)
|
241
241
|
END AS [length],
|
242
242
|
CASE
|
243
243
|
WHEN columns.IS_NULLABLE = 'YES' THEN 1
|
@@ -248,24 +248,24 @@ module ActiveRecord
|
|
248
248
|
ELSE NULL
|
249
249
|
END AS [is_primary],
|
250
250
|
c.is_identity AS [is_identity]
|
251
|
-
FROM #{database}INFORMATION_SCHEMA.COLUMNS columns
|
252
|
-
LEFT OUTER JOIN #{database}INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC
|
251
|
+
FROM #{database}.INFORMATION_SCHEMA.COLUMNS columns
|
252
|
+
LEFT OUTER JOIN #{database}.INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC
|
253
253
|
ON TC.TABLE_NAME = columns.TABLE_NAME
|
254
254
|
AND TC.CONSTRAINT_TYPE = N'PRIMARY KEY'
|
255
|
-
LEFT OUTER JOIN #{database}INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU
|
255
|
+
LEFT OUTER JOIN #{database}.INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU
|
256
256
|
ON KCU.COLUMN_NAME = columns.COLUMN_NAME
|
257
257
|
AND KCU.CONSTRAINT_NAME = TC.CONSTRAINT_NAME
|
258
258
|
AND KCU.CONSTRAINT_CATALOG = TC.CONSTRAINT_CATALOG
|
259
259
|
AND KCU.CONSTRAINT_SCHEMA = TC.CONSTRAINT_SCHEMA
|
260
|
-
INNER JOIN #{
|
260
|
+
INNER JOIN #{database}.sys.schemas AS s
|
261
261
|
ON s.name = columns.TABLE_SCHEMA
|
262
262
|
AND s.schema_id = s.schema_id
|
263
|
-
INNER JOIN #{
|
263
|
+
INNER JOIN #{database}.sys.objects AS o
|
264
264
|
ON s.schema_id = o.schema_id
|
265
265
|
AND o.is_ms_shipped = 0
|
266
266
|
AND o.type IN ('U', 'V')
|
267
267
|
AND o.name = columns.TABLE_NAME
|
268
|
-
INNER JOIN #{
|
268
|
+
INNER JOIN #{database}.sys.columns AS c
|
269
269
|
ON o.object_id = c.object_id
|
270
270
|
AND c.name = columns.COLUMN_NAME
|
271
271
|
WHERE columns.TABLE_NAME = @0
|
@@ -299,7 +299,7 @@ module ActiveRecord
|
|
299
299
|
if default.nil? && view_exists
|
300
300
|
default = select_value "
|
301
301
|
SELECT c.COLUMN_DEFAULT
|
302
|
-
FROM #{database}INFORMATION_SCHEMA.COLUMNS c
|
302
|
+
FROM #{database}.INFORMATION_SCHEMA.COLUMNS c
|
303
303
|
WHERE c.TABLE_NAME = '#{view_tblnm}'
|
304
304
|
AND c.COLUMN_NAME = '#{views_real_column_name(table_name, ci[:name])}'".squish, 'SCHEMA'
|
305
305
|
end
|
@@ -86,6 +86,14 @@ class UtilsTestSQLServer < ActiveRecord::TestCase
|
|
86
86
|
SQLServer::Utils.extract_identifiers('[obj.name].[foo]').quoted.must_equal '[obj.name].[foo]'
|
87
87
|
end
|
88
88
|
|
89
|
+
it 'can return fully qualified quoted table name' do
|
90
|
+
name = SQLServer::Utils.extract_identifiers('[server.name].[database].[schema].[object]')
|
91
|
+
name.fully_qualified_database_quoted.must_equal '[server.name].[database]'
|
92
|
+
|
93
|
+
name = SQLServer::Utils.extract_identifiers('server.database.schema.object')
|
94
|
+
name.fully_qualified_database_quoted.must_equal '[server].[database]'
|
95
|
+
end
|
96
|
+
|
89
97
|
end
|
90
98
|
|
91
99
|
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.
|
4
|
+
version: 4.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2015-11-
|
17
|
+
date: 2015-11-23 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|