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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54dab2a4b34d04529678804457e654cdf3c436b9
4
- data.tar.gz: 1719214a6ddc266cd8fad7dec68005cabd6ad9e8
3
+ metadata.gz: e84d27ebd75f08bcf37cf9243972440b0fc57280
4
+ data.tar.gz: f1f0a3e19713a80cdeba715025b4cb8523574c25
5
5
  SHA512:
6
- metadata.gz: 3ffd8586472a4bdbbd6a113919085029268a134b4eecc5b924c129e151518aa61a287f7e5120f5c755e28addb73a4a546136952b18d35265a78df8f775bce015
7
- data.tar.gz: 2ca086d538c72d86cd508e55cac63ebad56261dcc71eb4f13ae2bd8dd94cb4835b20a7e32acfe9ab551297b201d3af6eaa033fafe139ac1a7a6765d015662e6b
6
+ metadata.gz: f35f9ee3b2b34f7601f86d6867f2a86bf618203411e6e94ba4eec6b8d92f26cca09c63ae0596f50acacd4090fc644c4bfba43a3d2b7f2c33f849b170174d3cad
7
+ data.tar.gz: e59869fcb2a59c6a68a3778a56f7a1834becaec3c15844b44ed522115ca1a157cffe18c378b48cb697904188580171cdca76940f800377228c030ebc00c57233
@@ -1,4 +1,11 @@
1
1
 
2
+ ## v4.2.6
3
+
4
+ #### Fixed
5
+
6
+ * Allow linked servers for table names. Fixes #426. Thanks @jippeholwerda
7
+
8
+
2
9
  ## v4.2.5
3
10
 
4
11
  #### Removed
@@ -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 = "#{identifier.database_quoted}." if identifier.database_quoted
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 #{identifier.database_quoted}.sys.schemas AS s
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 #{identifier.database_quoted}.sys.objects AS o
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 #{identifier.database_quoted}.sys.columns AS c
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
@@ -39,6 +39,10 @@ module ActiveRecord
39
39
  server ? quote(server) : server
40
40
  end
41
41
 
42
+ def fully_qualified_database_quoted
43
+ [server_quoted, database_quoted].compact.join(SEPARATOR)
44
+ end
45
+
42
46
  def to_s
43
47
  quoted
44
48
  end
@@ -3,7 +3,7 @@ module ActiveRecord
3
3
  module SQLServer
4
4
  module Version
5
5
 
6
- VERSION = '4.2.5'
6
+ VERSION = '4.2.6'
7
7
 
8
8
  end
9
9
  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.5
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-22 00:00:00.000000000 Z
17
+ date: 2015-11-23 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: activerecord