activerecord-sqlserver-adapter 2.3.13 → 2.3.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,6 +1,16 @@
|
|
1
1
|
|
2
|
-
* 2
|
2
|
+
* 2.3.15 *
|
3
3
|
|
4
|
+
* Version bump due to bad 2.3.14 release.
|
5
|
+
|
6
|
+
|
7
|
+
* 2.3.14 *
|
8
|
+
|
9
|
+
* Flatten sp_helpconstraint when looking for constraints just in case fks are present. Issue #64.
|
10
|
+
|
11
|
+
* Properly quote table names when reflecting on views.
|
12
|
+
|
13
|
+
* Add "dead or not enabled" to :dblib's lost connection messages.
|
4
14
|
|
5
15
|
|
6
16
|
* 2.3.13 *
|
data/RUNNING_UNIT_TESTS
CHANGED
@@ -3,25 +3,29 @@
|
|
3
3
|
The default names for the test databases are "activerecord_unittest" and
|
4
4
|
"activerecord_unittest2". If you want to use another database name then be sure
|
5
5
|
to update the connection adapter setups you want to test with in
|
6
|
-
test/connections/<your database>/connection.rb.
|
6
|
+
test/connections/<your database>/connection.rb. Define a user named 'rails'
|
7
|
+
in SQL Server with all privileges granted for the test databases. Use an empty
|
8
|
+
password for said user.
|
7
9
|
|
8
10
|
The connection files make certain assumptions. For instance, the ODBC connection
|
9
11
|
assumes you have a DSN setup that matches the name of the default database names.
|
12
|
+
Review the test/connections/native_sqlserver_#{mode} file you are testing for details.
|
10
13
|
|
11
14
|
|
12
15
|
== Requirements
|
13
16
|
|
14
|
-
|
15
|
-
* gem install mocha
|
17
|
+
Get the development dependencies.
|
16
18
|
|
17
|
-
|
18
|
-
to checkout remotes/origin/2-3-stable, then make sure to export RAILS_SOURCE to
|
19
|
-
the full path of that repo.
|
20
|
-
|
21
|
-
Define a user named 'rails' in SQL Server with all privileges granted for the
|
22
|
-
test databases. Use an empty password for said user.
|
19
|
+
$ bundle install
|
23
20
|
|
21
|
+
The tests of this adapter depend on the existence of rails checkout. Make sure
|
22
|
+
to checkout remotes/origin/2-3-stable, I suggest using the git_remote_branch to
|
23
|
+
create a personal tracking branch. Then make a local topic branch off of that like
|
24
|
+
2-3-stable_sqlserver and commit this patch https://gist.github.com/761508 or you
|
25
|
+
will have around 90 some errors like this.
|
24
26
|
|
27
|
+
"Conversion failed when converting the nvarchar value 'Godfather' to data
|
28
|
+
type int.: INSERT INTO [items] ([name], [id]) VALUES (N'Godfather', 1)
|
25
29
|
|
26
30
|
|
27
31
|
|
@@ -147,7 +147,7 @@ module ActiveRecord
|
|
147
147
|
class SQLServerAdapter < AbstractAdapter
|
148
148
|
|
149
149
|
ADAPTER_NAME = 'SQLServer'.freeze
|
150
|
-
VERSION = '2.3.
|
150
|
+
VERSION = '2.3.15'.freeze
|
151
151
|
DATABASE_VERSION_REGEXP = /Microsoft SQL Server\s+(\d{4})/
|
152
152
|
SUPPORTED_VERSIONS = [2000,2005,2008].freeze
|
153
153
|
LIMITABLE_TYPES = ['string','integer','float','char','nchar','varchar','nvarchar'].to_set.freeze
|
@@ -158,7 +158,7 @@ module ActiveRecord
|
|
158
158
|
:adonet => ['TypeError','System::Data::SqlClient::SqlException']
|
159
159
|
}
|
160
160
|
LOST_CONNECTION_MESSAGES = {
|
161
|
-
:dblib => [/closed connection/],
|
161
|
+
:dblib => [/closed connection/, /dead or not enabled/],
|
162
162
|
:odbc => [/link failure/, /server failed/, /connection was already closed/, /invalid handle/i],
|
163
163
|
:adonet => [/current state is closed/, /network-related/]
|
164
164
|
}
|
@@ -593,7 +593,7 @@ module ActiveRecord
|
|
593
593
|
if view_info
|
594
594
|
view_info = view_info.with_indifferent_access
|
595
595
|
if view_info[:VIEW_DEFINITION].blank? || view_info[:VIEW_DEFINITION].length == 4000
|
596
|
-
view_info[:VIEW_DEFINITION] = info_schema_query { select_values("EXEC sp_helptext #{table_name}").join }
|
596
|
+
view_info[:VIEW_DEFINITION] = info_schema_query { select_values("EXEC sp_helptext #{quote_table_name(table_name)}").join }
|
597
597
|
end
|
598
598
|
end
|
599
599
|
view_info
|
@@ -1140,7 +1140,7 @@ module ActiveRecord
|
|
1140
1140
|
end
|
1141
1141
|
|
1142
1142
|
def remove_default_constraint(table_name, column_name)
|
1143
|
-
select_all("EXEC sp_helpconstraint '#{quote_string(table_name)}','nomsg'").select do |row|
|
1143
|
+
select_all("EXEC sp_helpconstraint '#{quote_string(table_name)}','nomsg'").flatten.select do |row|
|
1144
1144
|
row['constraint_type'] == "DEFAULT on column #{column_name}"
|
1145
1145
|
end.each do |row|
|
1146
1146
|
do_execute "ALTER TABLE #{quote_table_name(table_name)} DROP CONSTRAINT #{row['constraint_name']}"
|
@@ -13,6 +13,15 @@ end
|
|
13
13
|
|
14
14
|
class SpecificSchemaTestSqlserver < ActiveRecord::TestCase
|
15
15
|
|
16
|
+
should 'quote table names properly even when they are views' do
|
17
|
+
obj = SqlServerQuotedTable.create!
|
18
|
+
assert_nothing_raised { SqlServerQuotedTable.first }
|
19
|
+
obj = SqlServerQuotedView1.create!
|
20
|
+
assert_nothing_raised { SqlServerQuotedView1.first }
|
21
|
+
obj = SqlServerQuotedView2.create!
|
22
|
+
assert_nothing_raised { SqlServerQuotedView2.first }
|
23
|
+
end
|
24
|
+
|
16
25
|
should 'cope with multi line defaults' do
|
17
26
|
default = StringDefault.new
|
18
27
|
assert_equal "Some long default with a\nnew line.", default.string_with_multiline_default
|
@@ -33,6 +33,9 @@ class NumericData < ActiveRecord::Base ; self.table_name = 'numeric_data' ; end
|
|
33
33
|
class CustomersView < ActiveRecord::Base ; self.table_name = 'customers_view' ; end
|
34
34
|
class StringDefaultsView < ActiveRecord::Base ; self.table_name = 'string_defaults_view' ; end
|
35
35
|
class StringDefaultsBigView < ActiveRecord::Base ; self.table_name = 'string_defaults_big_view' ; end
|
36
|
+
class SqlServerQuotedTable < ActiveRecord::Base ; self.table_name = 'quoted-table' ; end
|
37
|
+
class SqlServerQuotedView1 < ActiveRecord::Base ; self.table_name = 'quoted-view1' ; end
|
38
|
+
class SqlServerQuotedView2 < ActiveRecord::Base ; self.table_name = 'quoted-view2' ; end
|
36
39
|
class SqlServerUnicode < ActiveRecord::Base ; end
|
37
40
|
class SqlServerString < ActiveRecord::Base ; end
|
38
41
|
class SqlServerChronic < ActiveRecord::Base
|
@@ -73,6 +73,13 @@ ActiveRecord::Schema.define do
|
|
73
73
|
execute %|ALTER TABLE [sql_server_edge_schemas] ADD [guid_newid] uniqueidentifier DEFAULT NEWID();|
|
74
74
|
execute %|ALTER TABLE [sql_server_edge_schemas] ADD [guid_newseqid] uniqueidentifier DEFAULT NEWSEQUENTIALID();| unless ActiveRecord::Base.connection.sqlserver_2000?
|
75
75
|
|
76
|
+
create_table 'quoted-table', :force => true do |t|
|
77
|
+
end
|
78
|
+
execute "IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'quoted-view1') DROP VIEW [quoted-view1]"
|
79
|
+
execute "CREATE VIEW [quoted-view1] AS SELECT * FROM [quoted-table]"
|
80
|
+
execute "IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'quoted-view2') DROP VIEW [quoted-view2]"
|
81
|
+
execute "CREATE VIEW [quoted-view2] AS \n /*#{'x'*4000}}*/ \n SELECT * FROM [quoted-table]"
|
82
|
+
|
76
83
|
execute "IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'customers_view') DROP VIEW customers_view"
|
77
84
|
execute <<-CUSTOMERSVIEW
|
78
85
|
CREATE VIEW customers_view AS
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 2.3.
|
9
|
+
- 15
|
10
|
+
version: 2.3.15
|
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:
|
22
|
+
date: 2011-03-01 00:00:00 -05:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
requirements: []
|
116
116
|
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.
|
118
|
+
rubygems_version: 1.5.0
|
119
119
|
signing_key:
|
120
120
|
specification_version: 3
|
121
121
|
summary: SQL Server 2000, 2005 and 2008 Adapter For Rails.
|