activerecord-sqlserver-adapter 3.0.14 → 3.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
|
2
|
-
* 3.0.
|
2
|
+
* 3.0.15 *
|
3
|
+
|
4
|
+
* Way better schema support! Thanks to @ianic! Fixes #61
|
5
|
+
|
6
|
+
* Warn of possible permission problems if "EXEC sp_helptext..." does not work view. Fixes #73.
|
7
|
+
|
8
|
+
|
9
|
+
* 3.0.13/3.0.14 *
|
3
10
|
|
4
11
|
* Allow TinyTDS/DBLIB mode to pass down :host/:port config options.
|
5
12
|
|
data/README.rdoc
CHANGED
@@ -9,7 +9,7 @@ module ActiveRecord
|
|
9
9
|
|
10
10
|
def tables(name = nil)
|
11
11
|
info_schema_query do
|
12
|
-
select_values "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties'"
|
12
|
+
select_values "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties' AND TABLE_SCHEMA = schema_name()"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -39,7 +39,7 @@ module ActiveRecord
|
|
39
39
|
|
40
40
|
def columns(table_name, name = nil)
|
41
41
|
return [] if table_name.blank?
|
42
|
-
cache_key =
|
42
|
+
cache_key = columns_cache_key(table_name)
|
43
43
|
@sqlserver_columns_cache[cache_key] ||= column_definitions(table_name).collect do |ci|
|
44
44
|
sqlserver_options = ci.except(:name,:default_value,:type,:null).merge(:database_year=>database_year)
|
45
45
|
SQLServerColumn.new ci[:name], ci[:default_value], ci[:type], ci[:null], sqlserver_options
|
@@ -175,6 +175,7 @@ module ActiveRecord
|
|
175
175
|
def column_definitions(table_name)
|
176
176
|
db_name = unqualify_db_name(table_name)
|
177
177
|
db_name_with_period = "#{db_name}." if db_name
|
178
|
+
table_schema = unqualify_table_schema(table_name)
|
178
179
|
table_name = unqualify_table_name(table_name)
|
179
180
|
sql = %{
|
180
181
|
SELECT
|
@@ -198,6 +199,7 @@ module ActiveRecord
|
|
198
199
|
END as is_identity
|
199
200
|
FROM #{db_name_with_period}INFORMATION_SCHEMA.COLUMNS columns
|
200
201
|
WHERE columns.TABLE_NAME = '#{table_name}'
|
202
|
+
AND columns.TABLE_SCHEMA = #{table_schema.nil? ? "schema_name() " : "'#{table_schema}' "}
|
201
203
|
ORDER BY columns.ordinal_position
|
202
204
|
}.gsub(/[ \t\r\n]+/,' ')
|
203
205
|
results = info_schema_query { select(sql,nil) }
|
@@ -266,6 +268,10 @@ module ActiveRecord
|
|
266
268
|
table_name.to_s.split('.').last.tr('[]','')
|
267
269
|
end
|
268
270
|
|
271
|
+
def unqualify_table_schema(table_name)
|
272
|
+
table_name.to_s.split('.')[-2].gsub(/[\[\]]/,'') rescue nil
|
273
|
+
end
|
274
|
+
|
269
275
|
def unqualify_db_name(table_name)
|
270
276
|
table_names = table_name.to_s.split('.')
|
271
277
|
table_names.length == 3 ? table_names.first.tr('[]','') : nil
|
@@ -306,7 +312,13 @@ module ActiveRecord
|
|
306
312
|
if view_info
|
307
313
|
view_info = view_info.with_indifferent_access
|
308
314
|
if view_info[:VIEW_DEFINITION].blank? || view_info[:VIEW_DEFINITION].length == 4000
|
309
|
-
view_info[:VIEW_DEFINITION] = info_schema_query
|
315
|
+
view_info[:VIEW_DEFINITION] = info_schema_query do
|
316
|
+
begin
|
317
|
+
select_values("EXEC sp_helptext #{quote_table_name(table_name)}").join
|
318
|
+
rescue
|
319
|
+
warn "No view definition found, possible permissions problem.\nPlease run GRANT VIEW DEFINITION TO your_user;"
|
320
|
+
end
|
321
|
+
end
|
310
322
|
end
|
311
323
|
end
|
312
324
|
view_info
|
@@ -320,12 +332,23 @@ module ActiveRecord
|
|
320
332
|
|
321
333
|
def views_real_column_name(table_name,column_name)
|
322
334
|
view_definition = view_information(table_name)[:VIEW_DEFINITION]
|
335
|
+
|
323
336
|
match_data = view_definition.match(/([\w-]*)\s+as\s+#{column_name}/im)
|
324
337
|
match_data ? match_data[1] : column_name
|
325
338
|
end
|
326
339
|
|
327
340
|
# === SQLServer Specific (Column/View Caches) =================== #
|
328
|
-
|
341
|
+
|
342
|
+
def columns_cache_key(table_name)
|
343
|
+
table_schema = unqualify_table_schema(table_name)
|
344
|
+
table_name = unqualify_table_name(table_name)
|
345
|
+
if table_schema
|
346
|
+
"#{table_schema}.#{table_name}"
|
347
|
+
else
|
348
|
+
table_name
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
329
352
|
def remove_sqlserver_columns_cache_for(table_name)
|
330
353
|
cache_key = unqualify_table_name(table_name)
|
331
354
|
@sqlserver_columns_cache[cache_key] = nil
|
@@ -17,7 +17,7 @@ module ActiveRecord
|
|
17
17
|
class Base
|
18
18
|
|
19
19
|
def self.sqlserver_connection(config) #:nodoc:
|
20
|
-
config = config.
|
20
|
+
config = config.symbolize_keys
|
21
21
|
config.reverse_merge! :mode => :dblib, :host => 'localhost', :username => 'sa', :password => ''
|
22
22
|
mode = config[:mode].to_s.downcase.underscore.to_sym
|
23
23
|
case mode
|
@@ -164,7 +164,7 @@ module ActiveRecord
|
|
164
164
|
include Sqlserver::Errors
|
165
165
|
|
166
166
|
ADAPTER_NAME = 'SQLServer'.freeze
|
167
|
-
VERSION = '3.0.
|
167
|
+
VERSION = '3.0.15'.freeze
|
168
168
|
DATABASE_VERSION_REGEXP = /Microsoft SQL Server\s+"?(\d{4}|\w+)"?/
|
169
169
|
SUPPORTED_VERSIONS = [2005,2008,2010,2011].freeze
|
170
170
|
|
@@ -295,7 +295,7 @@ module ActiveRecord
|
|
295
295
|
end
|
296
296
|
|
297
297
|
def sqlserver_azure?
|
298
|
-
@sqlserver_azure
|
298
|
+
@sqlserver_azure
|
299
299
|
end
|
300
300
|
|
301
301
|
def version
|
@@ -32,7 +32,9 @@ module Arel
|
|
32
32
|
# a colleciton of them reliably as well as using their true object attributes to mutate them
|
33
33
|
# to grouping objects for the inner sql during a select statment with an offset/rownumber. So this
|
34
34
|
# is here till ActiveRecord & ARel does this for us instead of using SqlLiteral objects.
|
35
|
+
alias :order_without_sqlserver :order
|
35
36
|
def order(*exprs)
|
37
|
+
return order_without_sqlserver(*exprs) unless Arel::Visitors::SQLServer === @visitor
|
36
38
|
@ast.orders.concat(exprs.map{ |x|
|
37
39
|
case x
|
38
40
|
when Arel::Attributes::Attribute
|
@@ -281,7 +283,7 @@ module Arel
|
|
281
283
|
core.projections.map do |x|
|
282
284
|
x.dup.tap do |p|
|
283
285
|
p.sub! 'DISTINCT', "DISTINCT #{visit(o.limit)}".strip if o.limit
|
284
|
-
p.
|
286
|
+
p.gsub! /\[?#{tn}\]?\./, '[__rnt].'
|
285
287
|
p.strip!
|
286
288
|
end
|
287
289
|
end
|
metadata
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-sqlserver-adapter
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.15
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 3
|
8
|
-
- 0
|
9
|
-
- 14
|
10
|
-
version: 3.0.14
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ken Collins
|
14
9
|
- Murray Steele
|
15
10
|
- Shawn Balestracci
|
@@ -18,51 +13,38 @@ authors:
|
|
18
13
|
autorequire:
|
19
14
|
bindir: bin
|
20
15
|
cert_chain: []
|
21
|
-
|
22
|
-
date: 2011-04-15 00:00:00 -04:00
|
16
|
+
date: 2011-04-27 00:00:00.000000000 -04:00
|
23
17
|
default_executable:
|
24
|
-
dependencies:
|
25
|
-
- !ruby/object:Gem::Dependency
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
26
20
|
name: activerecord
|
27
|
-
|
28
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
requirement: &2171190060 !ruby/object:Gem::Requirement
|
29
22
|
none: false
|
30
|
-
requirements:
|
23
|
+
requirements:
|
31
24
|
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
hash: 1
|
34
|
-
segments:
|
35
|
-
- 3
|
36
|
-
- 0
|
37
|
-
- 3
|
25
|
+
- !ruby/object:Gem::Version
|
38
26
|
version: 3.0.3
|
39
27
|
type: :runtime
|
40
|
-
version_requirements: *id001
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: arel
|
43
28
|
prerelease: false
|
44
|
-
|
29
|
+
version_requirements: *2171190060
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: arel
|
32
|
+
requirement: &2171189440 !ruby/object:Gem::Requirement
|
45
33
|
none: false
|
46
|
-
requirements:
|
34
|
+
requirements:
|
47
35
|
- - ~>
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
hash: 1
|
50
|
-
segments:
|
51
|
-
- 2
|
52
|
-
- 0
|
53
|
-
- 7
|
36
|
+
- !ruby/object:Gem::Version
|
54
37
|
version: 2.0.7
|
55
38
|
type: :runtime
|
56
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: *2171189440
|
57
41
|
description: SQL Server 2005 and 2008 Adapter For ActiveRecord
|
58
42
|
email: ken@metaskills.net
|
59
43
|
executables: []
|
60
|
-
|
61
44
|
extensions: []
|
62
|
-
|
63
|
-
extra_rdoc_files:
|
45
|
+
extra_rdoc_files:
|
64
46
|
- README.rdoc
|
65
|
-
files:
|
47
|
+
files:
|
66
48
|
- CHANGELOG
|
67
49
|
- MIT-LICENSE
|
68
50
|
- README.rdoc
|
@@ -80,37 +62,28 @@ files:
|
|
80
62
|
has_rdoc: true
|
81
63
|
homepage: http://github.com/rails-sqlserver/activerecord-sqlserver-adapter
|
82
64
|
licenses: []
|
83
|
-
|
84
65
|
post_install_message:
|
85
|
-
rdoc_options:
|
66
|
+
rdoc_options:
|
86
67
|
- --main
|
87
68
|
- README.rdoc
|
88
|
-
require_paths:
|
69
|
+
require_paths:
|
89
70
|
- lib
|
90
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
72
|
none: false
|
92
|
-
requirements:
|
93
|
-
- -
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
|
96
|
-
|
97
|
-
- 0
|
98
|
-
version: "0"
|
99
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
78
|
none: false
|
101
|
-
requirements:
|
102
|
-
- -
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
segments:
|
106
|
-
- 0
|
107
|
-
version: "0"
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
108
83
|
requirements: []
|
109
|
-
|
110
84
|
rubyforge_project: activerecord-sqlserver-adapter
|
111
85
|
rubygems_version: 1.6.2
|
112
86
|
signing_key:
|
113
87
|
specification_version: 3
|
114
88
|
summary: SQL Server 2005 and 2008 Adapter For ActiveRecord.
|
115
89
|
test_files: []
|
116
|
-
|