artpop-2000-2005-adapter 2.2.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGELOG +142 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +157 -0
  4. data/RUNNING_UNIT_TESTS +60 -0
  5. data/Rakefile +52 -0
  6. data/autotest/discover.rb +4 -0
  7. data/autotest/railssqlserver.rb +16 -0
  8. data/autotest/sqlserver.rb +54 -0
  9. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1014 -0
  10. data/lib/core_ext/active_record.rb +133 -0
  11. data/lib/core_ext/dbi.rb +85 -0
  12. data/lib/rails-sqlserver-2000-2005-adapter.rb +1 -0
  13. data/test/cases/aaaa_create_tables_test_sqlserver.rb +19 -0
  14. data/test/cases/adapter_test_sqlserver.rb +627 -0
  15. data/test/cases/attribute_methods_test_sqlserver.rb +33 -0
  16. data/test/cases/basics_test_sqlserver.rb +21 -0
  17. data/test/cases/calculations_test_sqlserver.rb +20 -0
  18. data/test/cases/column_test_sqlserver.rb +264 -0
  19. data/test/cases/connection_test_sqlserver.rb +103 -0
  20. data/test/cases/eager_association_test_sqlserver.rb +42 -0
  21. data/test/cases/execute_procedure_test_sqlserver.rb +33 -0
  22. data/test/cases/inheritance_test_sqlserver.rb +28 -0
  23. data/test/cases/method_scoping_test_sqlserver.rb +28 -0
  24. data/test/cases/migration_test_sqlserver.rb +93 -0
  25. data/test/cases/offset_and_limit_test_sqlserver.rb +89 -0
  26. data/test/cases/pessimistic_locking_test_sqlserver.rb +125 -0
  27. data/test/cases/query_cache_test_sqlserver.rb +24 -0
  28. data/test/cases/schema_dumper_test_sqlserver.rb +61 -0
  29. data/test/cases/specific_schema_test_sqlserver.rb +26 -0
  30. data/test/cases/sqlserver_helper.rb +119 -0
  31. data/test/cases/table_name_test_sqlserver.rb +22 -0
  32. data/test/cases/transaction_test_sqlserver.rb +93 -0
  33. data/test/cases/unicode_test_sqlserver.rb +44 -0
  34. data/test/connections/native_sqlserver/connection.rb +23 -0
  35. data/test/connections/native_sqlserver_odbc/connection.rb +25 -0
  36. data/test/migrations/transaction_table/1_table_will_never_be_created.rb +11 -0
  37. data/test/schema/sqlserver_specific_schema.rb +88 -0
  38. metadata +96 -0
@@ -0,0 +1,142 @@
1
+
2
+ MASTER
3
+
4
+ *
5
+
6
+
7
+ * 2.2.15 * (March 23rd, 2009)
8
+
9
+ * Better add_lock! method that can add the lock to just about all the elements in the statement. This
10
+ could be eager loaded associations, joins, etc. Done so that paginated results can easily add lock
11
+ options for performance. Note, the tally count in add_limit_offset! use "WITH (NOLOCK)" explicitly
12
+ as it can not hurt and is needed. [Ken Collins]
13
+
14
+
15
+ * 2.2.14 * (March 17th, 2009)
16
+
17
+ * Rails2.3 - Back passing tests on 2.2 work. Includes: (1) Created new test helpers that check ActiveRecord
18
+ version strings so we can conditionally run 2.2 and 2.3 tests. (2) Making TransactionTestSqlserver use Ship vs
19
+ Bird model. Also made it conditional run a few blocks for different versions of ActiveRecord. (3) Previous
20
+ JoinDependency#aliased_table_name_for is now only patched in ActiveRecord equal or greater than 2.3. [Ken Collins]
21
+
22
+ * Rails2.3 - Implement new savepoint support [Ken Collins]
23
+ http://rails.lighthouseapp.com/projects/8994/tickets/383
24
+ http://www.codeproject.com/KB/database/sqlservertransactions.aspx
25
+
26
+ * Rails2.3 - Coerce NestedScopingTest#test_merged_scoped_find to use correct regexp for adapter. [Ken Collins]
27
+
28
+ * Rails2.3 - Implement a custom ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation#aliased_table_name_for
29
+ method that uses a Regexp.escape so that table/column quoting does not get ignored. [Ken Collins]
30
+
31
+ * Rails2.3 - Implement #outside_transaction? and a new transaction test case to test some SQL Server
32
+ basic support while implementing this method. Future home of some savepoint tests too. [Ken Collins]
33
+
34
+ * Rails2.3 - Coerced tests that ensure hash conditions on referenced tables are considered when eager
35
+ loading with limit/offset. Information on these changes and the ticket in rails are.
36
+ http://github.com/rails/rails/commit/9a4d557713acb0fc8e80f61af18094034aca029a
37
+ http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1404-conditions_tables-doesnt-understand-condition-hashes
38
+
39
+ * Rails2.3 - Add coerced tests for true/false attributes in selects use SQL Server case statement. [Ken Collins]
40
+
41
+ * Making sure that smalldatetime types are OK to use. Also fixed a bug in the #view_information method that
42
+ checks to see if a view definition is equal to 4000 chars, meaning that it is most likely truncated and
43
+ needs to use the backup method of sp_helptext to get it's view definition. [Ken Collins]
44
+
45
+
46
+ * 2.2.13 * (February 10th, 2009)
47
+
48
+ * Update #indexes to use unqualified table name. Fixes cases where users may decide to use table
49
+ name prefixes like 'dbo.'. [Ken Collins]
50
+
51
+
52
+ * 2.2.12 * (February 8th, 2009)
53
+
54
+ * Update table_exists? to work with qualified table names that may include an user prefix. [Ken Collins]
55
+
56
+
57
+ * 2.2.10/11 * (January 22nd, 2009)
58
+
59
+ * Add a rails-sqlserver-2000-2005-adapter.rb file so that long :lib option for config.gem is no longer needed.
60
+
61
+
62
+ * 2.2.9 * (January 22nd, 2009)
63
+
64
+ * Fixing a small bug in the deprecated DBI::Timestamp conversion so it correctly converts nanosecond whole
65
+ numbers to back to pre type cast SQL Server milliseconds, ultimately allow ruby's Time#usec which is
66
+ microseconds to be correct. [Ken Collins]
67
+
68
+ * Sometimes views are more than 4000 chars long and will return NULL for the VIEW_DEFINITION. If so, use
69
+ sp_helptext procedure as a backup method. [Ken Collins]
70
+
71
+
72
+ * 2.2.8 (January 9th, 2009)
73
+
74
+ * Update execute_procedure method a bit to remove excess code. [Ken Collins]
75
+
76
+
77
+ * 2.2.7 (January 9th, 2009)
78
+
79
+ * Created a connection#execute_procedure method that takes can take any number of ruby objects as variables
80
+ and quotes them according to the connection's rules. Also added an ActiveRecord::Base class level core
81
+ extension that hooks into this. It also checks if the connection responds to #execute_procedure and if
82
+ not returns an empty array. [Ken Collins]
83
+
84
+ * Added a #enable_default_unicode_types class attribute access to make all new added or changed string types
85
+ like :string/:text default to unicode/national data types. See the README for full details. Added a rake
86
+ task that assists setting this to true when running tests. [Ken Collins]
87
+
88
+
89
+ * 2.2.6 (January 8th, 2009)
90
+
91
+ * Introduced a bug in 2.2.5 in the #add_order! core ext for ActiveRecord. Fixed [Ken Collins]
92
+
93
+
94
+ * 2.2.5 (January 4th, 2009)
95
+
96
+ * Added a log_info_schema_queries class attribute and make all queries to INFORMATION_SCHEMA silent by
97
+ default. [Ken Collins]
98
+
99
+ * Fix millisecond support in datetime columns. ODBC::Timestamp incorrectly takes SQL Server milliseconds
100
+ and applies them as nanoseconds. We cope with this at the DBI layer by using SQLServerDBI::Type::SqlserverTimestamp
101
+ class to parse the before type cast value appropriately. Also update the adapters #quoted_date method
102
+ to work more simply by converting ruby's #usec milliseconds to SQL Server microseconds. [Ken Collins]
103
+
104
+ * Core extensions for ActiveRecord now reflect on the connection before doing SQL Server things. Now
105
+ this adapter is compatible for using with other adapters. [Ken Collins]
106
+
107
+
108
+ * 2.2.4 (December 5th, 2008)
109
+
110
+ * Fix a type left in #views_real_column_name. Also cache #view_information lookups. [Ken Collins]
111
+
112
+
113
+ * 2.2.3 (December 5th, 2008)
114
+
115
+ * Changing back to using real table name in column_definitions. Makes sure views get back only the columns
116
+ that are defined for them with correct names, etc. Now supporting views by looking for NULL default and
117
+ then if table name is a view, perform a targeted with sub select to the real table name and column name
118
+ to find true default. [Ken Collins]
119
+
120
+ * Ensure that add_limit_offset! does not alter sub queries. [Erik Bryn]
121
+
122
+
123
+ 2.2.2 (December 2nd, 2008)
124
+
125
+ * Add support for view defaults by making column_definitions use real table name for schema info. [Ken Collins]
126
+
127
+ * Include version in connection method and inspection. [Ken Collins]
128
+
129
+
130
+ 2.2.1 (November 25th, 2008)
131
+
132
+ * Add identity insert support for views. Cache #views so that identity #table_name_or_views_table_name
133
+ will run quickly. [Ken Collins]
134
+
135
+ * Add views support. ActiveRecord classes can use views. The connection now has a #views method and
136
+ #table_exists? will now fall back to checking views too. [Ken Collins]
137
+
138
+
139
+ 2.2.0 (November 21st, 2008)
140
+
141
+ * Release for rails 2.2.2. Many many changes. [Ken Collins], [Murray Steele], [Shawn Balestracci], [Joe Rafaniello]
142
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,157 @@
1
+
2
+ == Rails SQL Server 2000 & 2005 Adapter
3
+
4
+ The SQL Server adapter for rails is back for ActiveRecord 2.2 and up! We are currently passing all tests and hope to continue to do so moving forward.
5
+
6
+
7
+ == What's New
8
+
9
+ * Now supports both rails 2.2 & 2.3!!!
10
+ * An ActiveRecord::Base.execute_procedure method that can be used by classes.
11
+ * Enabled support for DDL transactions.
12
+ * Micro second support. Time#usec is automatically converted to SQL Server's 3.33 millisecond limitation.
13
+ * Datetime data types before type casting are represented correctly. For example: 1998-01-01 23:59:59.997
14
+ * Implementation for #disable_referential_integrity used by ActiveRecord's Fixtures class.
15
+ * Pessimistic locking suppot. See the #add_lock! method for details.
16
+ * Enabled #case_sensitive_equality_operator used by unique validations.
17
+ * Unicode character support for nchar, nvarchar and ntext data types. Configuration option for defaulting all string data types to the unicode safe types.
18
+ * View support for table names, identity inserts, and column defaults.
19
+
20
+ ==== Date/Time Data Type Hinting
21
+
22
+ Both SQL Server 2000 and 2005 do not have native data types for just 'date' or 'time', it only has 'datetime'. To pass the ActiveRecord tests we implemented two simple class methods that can teach your models to coerce column information to be cast correctly. Simply past a list of symbols to either the <tt>coerce_sqlserver_date</tt> or <tt>coerce_sqlserver_time</tt> methods that correspond to 'datetime' columns that need to be cast correctly.
23
+
24
+ class Topic < ActiveRecord::Base
25
+ coerce_sqlserver_date :last_read
26
+ coerce_sqlserver_time :bonus_time
27
+ end
28
+
29
+ This implementation has some limitations. To date we can only coerce date/time types for models that conform to the expected ActiveRecord class to table naming convention. So a table of 'foo_bar_widgets' will look for coerced types in the FooBarWidget class if it exists.
30
+
31
+ ==== Executing Stored Procedures
32
+
33
+ Every class that sub classes ActiveRecord::Base will now have an execute_procedure class method to use. This method takes the name of the stored procedure which can be a string or symbol and any number of variables to pass to the procedure. Arguments will automatically be quoted per the connection's standards as normal. For example.
34
+
35
+ Account.execute_procedure :update_totals, 'admin', nil, true
36
+
37
+ ==== Native Data Type Support
38
+
39
+ Currently the following custom data types have been tested for schema definitions.
40
+
41
+ * char
42
+ * nchar
43
+ * nvarchar
44
+ * ntext
45
+ * varchar(max) for SQL Server 2005 only.
46
+ * nvarchar(max) for SQL Server 2005 only.
47
+
48
+ For example:
49
+
50
+ create_table :sql_server_custom_types, :force => true do |t|
51
+ t.column :ten_code, :char, :limit => 10
52
+ t.column :ten_code_utf8, :nchar, :limit => 10
53
+ t.column :title_utf8, :nvarchar
54
+ t.column :body, :varchar_max # Creates varchar(max)
55
+ t.column :body_utf8, :ntext
56
+ t.column :body2_utf8, :nvarchar_max # Creates nvarchar(max)
57
+ end
58
+
59
+ Manually creating a varchar(max) on SQL Server 2005 is not necessary since this is the default type created when specifying a :text field. As time goes on we will be testing other SQL Server specific data types are handled correctly when created in a migration.
60
+
61
+
62
+ ==== Native Text/String/Binary Data Type Accessor
63
+
64
+ To pass the ActiveRecord tests we had to implement an class accessor for the native type created for :text columns. By default any :text column created by migrations will create these native types.
65
+
66
+ * SQL Server 2000 is 'text'
67
+ * SQL Server 2005 is 'varchar(max)'
68
+
69
+ During testing this type is set to 'varchar(8000)' for SQL Server 2000. The reason is that rails expects to be able to use SQL = operators on text data types and this is not possible with a native 'text' data type in SQL Server. The default 'varchar(max)' for SQL Server 2005 can be queried using the SQL = operator and has plenty of storage space which is why we made it the default for 2005. If for some reason you want to change the data type created during migrations for any SQL Server version, you can configure this line to your liking in a config/initializers file.
70
+
71
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'varchar(8000)'
72
+
73
+ Also, there is a class attribute setter for the native string database type. This is the same for both SQL Server 2000 and 2005, 'varchar'. However in can be used instead of the #enable_default_unicode_types below for finer grain control over which types you want unicode safe when adding or changing the schema.
74
+
75
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_string_database_type = 'nvarchar'
76
+
77
+ By default any :binary column created by migrations will create these native types
78
+
79
+ * SQL Server 2000 is 'image'
80
+ * SQL Server 2005 is 'varbinary(max)'
81
+
82
+
83
+ ==== Setting Unicode Types As Default
84
+
85
+ By default the adapter will use non-unicode safe data types for :string and :text types when DEFINING or CHANGING the schema. If you choose, you can set the following class attribute in a config/initializers file that will change this behavior. When set to true it has the equivalent meaning as the two lower items. These examples show detail level alternatives to achieve similar effects.
86
+
87
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.enable_default_unicode_types = true
88
+
89
+ # SQL Server 2000
90
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'ntext'
91
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_string_database_type = 'nvarchar'
92
+
93
+ # SQL Server 2005
94
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'nvarchar(max)'
95
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_string_database_type = 'nvarchar'
96
+
97
+ It is important to remember that unicode types in SQL Server have approximately half the storage capacity as their counter parts. So where a normal string would max out at (8000) a unicode string will top off at (4000).
98
+
99
+
100
+ ==== Schema Information Logging
101
+
102
+ By default all queries to the INFORMATION_SCHEMA table is silenced. If you think logging these queries are useful, you can enable it by adding this like to a config/initializers file.
103
+
104
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.log_info_schema_queries = true
105
+
106
+
107
+ == Versions
108
+
109
+ It is our goal to match the adapter version with each version of rails. However we will track our own tiny version independent of ActiveRecord. For example, an adapter version of 2.2.x will work on any 2.2.x version of ActiveRecord. This convention will be used in both the Git tags as well as the Rubygems versioning.
110
+
111
+
112
+ == Installation
113
+
114
+ First, you will need Ruby DBI and Ruby ODBC. To my knowledge the ADO DBD for DBI is no longer supported. The installation below is not a comprehensive walk thru on how to get all the required moving parts like FreeTDS installed and/or configured. It will also assume gem installations of both the dependent libraries and the adapter itself.
115
+
116
+ It should be noted that this version of the adapter was developed using both the ancient 0.0.23 version of DBI up to the current stable release of 0.4.0. Because later versions of DBI will be changing many things, IT IS HIGHLY RECOMMENDED that you max your install to version 0.4.0 which the examples below show. For the time being we are not supporting DBI versions higher than 0.4.0. The good news is that if you were using a very old DBI with ADO, technically this adapter will still work for you, but be warned your path is getting old and may not be supported for long.
117
+
118
+ $ gem install dbi --version 0.4.0
119
+ $ gem install dbd-odbc --version 0.2.4
120
+ $ gem install rails-sqlserver-2000-2005-adapter -s http://gems.github.com
121
+
122
+ Optionally configure your gem dependencies in your rails environment.rb file.
123
+
124
+ config.gem 'dbi', :version => '0.4.0'
125
+ config.gem 'dbd-odbc', :version => '0.2.4', :lib => 'dbd/ODBC'
126
+ config.gem 'rails-sqlserver-2000-2005-adapter', :source => 'http://gems.github.com'
127
+
128
+ Here are some external links for libraries and/or tutorials on how to install any other additional components to use this adapter. If you know of a good one that we can include here, just let us know.
129
+
130
+ * http://ruby-dbi.sourceforge.net/
131
+ * http://www.ch-werner.de/rubyodbc/
132
+
133
+
134
+ == Contributing
135
+
136
+ If you’d like to contribute a feature or bugfix, thanks! To make sure your fix/feature has a high chance of being added, please read the following guidelines. First, ask on the Google list, IRC, or post a ticket in Lighthouse. Second, make sure there are tests! We will not accept any patch that is not tested. Please read the RUNNING_UNIT_TESTS file for the details of how to run the unit tests.
137
+
138
+ * Lighthouse: http://rails-sqlserver.lighthouseapp.com/projects/20277-sql-server-05-adapter/tickets
139
+ * Google Group: http://groups.google.com/group/rails-sqlserver-adapter
140
+ * IRC Room: #rails-sqlserver on irc.freenode.net
141
+
142
+
143
+ == Credits
144
+
145
+ Many many people have contributed. If you do not see your name here and it should be let us know.
146
+
147
+ * Ken Collins
148
+ * Murray Steele
149
+ * Shawn Balestracci
150
+ * Joe Rafaniello
151
+ * Tom Ward
152
+
153
+
154
+ == License
155
+
156
+ Copyright © 2008. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
157
+
@@ -0,0 +1,60 @@
1
+ == Creating the test database
2
+
3
+ The default names for the test databases are "activerecord_unittest" and
4
+ "activerecord_unittest2". If you want to use another database name then be sure
5
+ to update the connection adapter setups you want to test with in
6
+ test/connections/<your database>/connection.rb.
7
+
8
+
9
+ == Requirements
10
+
11
+ The following gems need to be installed. Make sure you have gems.github.com as a
12
+ source. http://github.com/blog/97-github-loves-rubygems-1-2
13
+
14
+ * gem install thoughtbot-shoulda -s http://gems.github.com
15
+ * gem install mocha
16
+
17
+ The tests of this adapter depend on the existence of rails checkout. All the tests
18
+ defined by rails are re-used. For this to work the following directory structure
19
+ is assumed to exist:
20
+
21
+ #{RAILS_ROOT}/vendor/plugins/adapters/sqlserver
22
+ #{RAILS_ROOT}/vendor/rails/activerecord/test
23
+
24
+ Define a user named 'rails' in SQL Server with all privileges granted. Use an empty
25
+ password for user 'rails', or alternatively use the OSQLPASSWORD environment variable
26
+ which allows you to set a default password for the current session.
27
+
28
+ Then run "rake create_databases".
29
+
30
+
31
+ == Running with Rake
32
+
33
+ The easiest way to run the unit tests is through Rake. Either run "rake test_sqlserver"
34
+ or "rake test_sqlserver_odbc". For more information, checkout the full array
35
+ of rake tasks with "rake -T"
36
+
37
+ Rake can be found at http://rake.rubyforge.org
38
+
39
+
40
+ == Running with Autotest
41
+
42
+ Using autotest is easy, just run "autotest" and the tests will run continually in the
43
+ same order as the rake test command. By default autotest will use ODBC connection. If
44
+ you want to change this you can edit the autotest/sqlserver.rb file and set odbc_mode
45
+ to false.
46
+
47
+ Lastly, you can run autotest on just the adapter specific tests with "autotest sqlserver".
48
+ This will continuously run ONLY the SQL Sever specific behavior tests which are much
49
+ quicker to run than the entire active record test suite.
50
+
51
+
52
+ == Running by hand
53
+
54
+ Unit tests are located in test directory. If you only want to run a single test suite,
55
+ you can do so with:
56
+
57
+ rake test_sqlserver TEST=base_test.rb
58
+
59
+ That'll run the base suite using the SQLServer-Ruby adapter.
60
+
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
5
+
6
+ desc 'Create the SQL Server test databases'
7
+ task :create_databases do
8
+ # Define a user named 'rails' in SQL Server with all privileges granted
9
+ # Use an empty password for user 'rails', or alternatively use the OSQLPASSWORD environment variable
10
+ # which allows you to set a default password for the current session.
11
+ %x( osql -S localhost -U rails -Q "create database activerecord_unittest" -P )
12
+ %x( osql -S localhost -U rails -Q "create database activerecord_unittest2" -P )
13
+ %x( osql -S localhost -U rails -d activerecord_unittest -Q "exec sp_grantdbaccess 'rails'" -P )
14
+ %x( osql -S localhost -U rails -d activerecord_unittest2 -Q "exec sp_grantdbaccess 'rails'" -P )
15
+ %x( osql -S localhost -U rails -d activerecord_unittest -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
16
+ %x( osql -S localhost -U rails -d activerecord_unittest2 -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
17
+ end
18
+
19
+ desc 'Drop the SQL Server test databases'
20
+ task :drop_databases do
21
+ %x( osql -S localhost -U rails -Q "drop database activerecord_unittest" -P )
22
+ %x( osql -S localhost -U rails -Q "drop database activerecord_unittest2" -P )
23
+ end
24
+
25
+ desc 'Recreate the SQL Server test databases'
26
+ task :recreate_databases => [:drop_databases, :create_databases]
27
+
28
+
29
+ for adapter in %w( sqlserver sqlserver_odbc )
30
+
31
+ Rake::TestTask.new("test_#{adapter}") { |t|
32
+ t.libs << "test"
33
+ t.libs << "test/connections/native_#{adapter}"
34
+ t.libs << "../../../rails/activerecord/test/"
35
+ t.test_files = (
36
+ Dir.glob("test/cases/**/*_test_sqlserver.rb").sort +
37
+ Dir.glob("../../../rails/activerecord/test/**/*_test.rb").sort )
38
+ t.verbose = true
39
+ }
40
+
41
+ namespace adapter do
42
+ task :test => "test_#{adapter}"
43
+ end
44
+
45
+ end
46
+
47
+ desc 'Test with unicode types enabled.'
48
+ Rake::TestTask.new(:test_unicode_types) do |t|
49
+ ENV['ENABLE_DEFAULT_UNICODE_TYPES'] = 'true'
50
+ test = Rake::Task['test_sqlserver_odbc']
51
+ test.invoke
52
+ end
@@ -0,0 +1,4 @@
1
+
2
+ Autotest.add_discovery do
3
+ ARGV.first || 'railssqlserver'
4
+ end
@@ -0,0 +1,16 @@
1
+ require 'autotest/sqlserver'
2
+
3
+ class Autotest::Railssqlserver < Autotest::Sqlserver
4
+
5
+ def initialize
6
+ super
7
+ self.libs << "#{File::PATH_SEPARATOR}../../../rails/activerecord/test/"
8
+ self.extra_files = ['../../../rails/activerecord/test/']
9
+ self.add_mapping %r%../../../rails/activerecord/test/.*/.*_test.rb$% do |filename, _|
10
+ filename
11
+ end
12
+ end
13
+
14
+
15
+ end
16
+