activerecord-sqlserver-adapter 2.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/CHANGELOG +175 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Manifest +36 -0
  4. data/README.rdoc +175 -0
  5. data/RUNNING_UNIT_TESTS +60 -0
  6. data/Rakefile +18 -0
  7. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1126 -0
  8. data/lib/activerecord-sqlserver-adapter.rb +1 -0
  9. data/lib/core_ext/active_record.rb +133 -0
  10. data/lib/core_ext/dbi.rb +85 -0
  11. data/tasks/sqlserver.rake +31 -0
  12. data/test/cases/aaaa_create_tables_test_sqlserver.rb +19 -0
  13. data/test/cases/adapter_test_sqlserver.rb +707 -0
  14. data/test/cases/attribute_methods_test_sqlserver.rb +33 -0
  15. data/test/cases/basics_test_sqlserver.rb +21 -0
  16. data/test/cases/calculations_test_sqlserver.rb +20 -0
  17. data/test/cases/column_test_sqlserver.rb +264 -0
  18. data/test/cases/connection_test_sqlserver.rb +142 -0
  19. data/test/cases/eager_association_test_sqlserver.rb +42 -0
  20. data/test/cases/execute_procedure_test_sqlserver.rb +33 -0
  21. data/test/cases/inheritance_test_sqlserver.rb +28 -0
  22. data/test/cases/method_scoping_test_sqlserver.rb +28 -0
  23. data/test/cases/migration_test_sqlserver.rb +93 -0
  24. data/test/cases/offset_and_limit_test_sqlserver.rb +108 -0
  25. data/test/cases/pessimistic_locking_test_sqlserver.rb +125 -0
  26. data/test/cases/query_cache_test_sqlserver.rb +24 -0
  27. data/test/cases/schema_dumper_test_sqlserver.rb +72 -0
  28. data/test/cases/specific_schema_test_sqlserver.rb +57 -0
  29. data/test/cases/sqlserver_helper.rb +123 -0
  30. data/test/cases/table_name_test_sqlserver.rb +22 -0
  31. data/test/cases/transaction_test_sqlserver.rb +93 -0
  32. data/test/cases/unicode_test_sqlserver.rb +50 -0
  33. data/test/connections/native_sqlserver/connection.rb +23 -0
  34. data/test/connections/native_sqlserver_odbc/connection.rb +25 -0
  35. data/test/migrations/transaction_table/1_table_will_never_be_created.rb +11 -0
  36. data/test/schema/sqlserver_specific_schema.rb +91 -0
  37. metadata +120 -0
@@ -0,0 +1,175 @@
1
+
2
+ MASTER
3
+
4
+
5
+ * 2.2.18 * (June 5th, 2009)
6
+
7
+ * Column reflection on table name rescues LoadError and a few others. Resolves tickets #25 & #33 [Ken Collins]
8
+
9
+ * Added 2008 support. Resolves ticket #32 [Ken Collins]
10
+
11
+
12
+ * 2.2.17 * (May 14th, 2009)
13
+
14
+ * Add simplified type recognition for varchar(max) and nvarchar(max) under SQL Server 2005 to be a
15
+ :text type. This ensures schema dumper does the right thing. Fixes ticket #30. [Ken Collins]
16
+
17
+ * Tested ruby 1.9, ruby-odbc 0.9996, and DBI 0.4.1. Also added correct support for UTF-8 character
18
+ encoding going in and out of the DB. See before gist http://gist.github.com/111709 and after gist
19
+ http://gist.github.com/111719 [Ken Collins]
20
+
21
+
22
+ * 2.2.16 * (April 21st, 2009)
23
+
24
+ * Make add_limit_offset! only add locking hints (for tally) when the :lock option is present. Added tests
25
+ to make sure tally SQL is augmented correctly and tests to make sure that add_lock! is doing what it needs
26
+ for deep sub selects in paginated results. [Ken Collins]
27
+
28
+ * Add auto reconnect support utilizing a new #with_auto_reconnect block. By default each query run through
29
+ the adapter will automatically reconnect at standard intervals, logging attempts along the way, till success
30
+ or the original exception bubbles up. See docs for more details. Resolves ticket #18 [Ken Collins]
31
+
32
+ * Update internal helper method #orders_and_dirs_set to cope with an order clause like "description desc". This
33
+ resolves ticket #26 [Ken Collins]
34
+
35
+ * Provide support for running queries at different isolation levels using #run_with_isolation_level method
36
+ that can take a block or not. Also implement a #user_options method that reflects on the current user
37
+ session values. Resolves #20 [Murray Steele]
38
+
39
+
40
+ * 2.2.15 * (March 23rd, 2009)
41
+
42
+ * Better add_lock! method that can add the lock to just about all the elements in the statement. This
43
+ could be eager loaded associations, joins, etc. Done so that paginated results can easily add lock
44
+ options for performance. Note, the tally count in add_limit_offset! use "WITH (NOLOCK)" explicitly
45
+ as it can not hurt and is needed. [Ken Collins]
46
+
47
+
48
+ * 2.2.14 * (March 17th, 2009)
49
+
50
+ * Rails2.3 - Back passing tests on 2.2 work. Includes: (1) Created new test helpers that check ActiveRecord
51
+ version strings so we can conditionally run 2.2 and 2.3 tests. (2) Making TransactionTestSqlserver use Ship vs
52
+ Bird model. Also made it conditional run a few blocks for different versions of ActiveRecord. (3) Previous
53
+ JoinDependency#aliased_table_name_for is now only patched in ActiveRecord equal or greater than 2.3. [Ken Collins]
54
+
55
+ * Rails2.3 - Implement new savepoint support [Ken Collins]
56
+ http://rails.lighthouseapp.com/projects/8994/tickets/383
57
+ http://www.codeproject.com/KB/database/sqlservertransactions.aspx
58
+
59
+ * Rails2.3 - Coerce NestedScopingTest#test_merged_scoped_find to use correct regexp for adapter. [Ken Collins]
60
+
61
+ * Rails2.3 - Implement a custom ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation#aliased_table_name_for
62
+ method that uses a Regexp.escape so that table/column quoting does not get ignored. [Ken Collins]
63
+
64
+ * Rails2.3 - Implement #outside_transaction? and a new transaction test case to test some SQL Server
65
+ basic support while implementing this method. Future home of some savepoint tests too. [Ken Collins]
66
+
67
+ * Rails2.3 - Coerced tests that ensure hash conditions on referenced tables are considered when eager
68
+ loading with limit/offset. Information on these changes and the ticket in rails are.
69
+ http://github.com/rails/rails/commit/9a4d557713acb0fc8e80f61af18094034aca029a
70
+ http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1404-conditions_tables-doesnt-understand-condition-hashes
71
+
72
+ * Rails2.3 - Add coerced tests for true/false attributes in selects use SQL Server case statement. [Ken Collins]
73
+
74
+ * Making sure that smalldatetime types are OK to use. Also fixed a bug in the #view_information method that
75
+ checks to see if a view definition is equal to 4000 chars, meaning that it is most likely truncated and
76
+ needs to use the backup method of sp_helptext to get it's view definition. [Ken Collins]
77
+
78
+
79
+ * 2.2.13 * (February 10th, 2009)
80
+
81
+ * Update #indexes to use unqualified table name. Fixes cases where users may decide to use table
82
+ name prefixes like 'dbo.'. [Ken Collins]
83
+
84
+
85
+ * 2.2.12 * (February 8th, 2009)
86
+
87
+ * Update table_exists? to work with qualified table names that may include an user prefix. [Ken Collins]
88
+
89
+
90
+ * 2.2.10/11 * (January 22nd, 2009)
91
+
92
+ * Add a rails-sqlserver-2000-2005-adapter.rb file so that long :lib option for config.gem is no longer needed.
93
+
94
+
95
+ * 2.2.9 * (January 22nd, 2009)
96
+
97
+ * Fixing a small bug in the deprecated DBI::Timestamp conversion so it correctly converts nanosecond whole
98
+ numbers to back to pre type cast SQL Server milliseconds, ultimately allow ruby's Time#usec which is
99
+ microseconds to be correct. [Ken Collins]
100
+
101
+ * Sometimes views are more than 4000 chars long and will return NULL for the VIEW_DEFINITION. If so, use
102
+ sp_helptext procedure as a backup method. [Ken Collins]
103
+
104
+
105
+ * 2.2.8 (January 9th, 2009)
106
+
107
+ * Update execute_procedure method a bit to remove excess code. [Ken Collins]
108
+
109
+
110
+ * 2.2.7 (January 9th, 2009)
111
+
112
+ * Created a connection#execute_procedure method that takes can take any number of ruby objects as variables
113
+ and quotes them according to the connection's rules. Also added an ActiveRecord::Base class level core
114
+ extension that hooks into this. It also checks if the connection responds to #execute_procedure and if
115
+ not returns an empty array. [Ken Collins]
116
+
117
+ * Added a #enable_default_unicode_types class attribute access to make all new added or changed string types
118
+ like :string/:text default to unicode/national data types. See the README for full details. Added a rake
119
+ task that assists setting this to true when running tests. [Ken Collins]
120
+
121
+
122
+ * 2.2.6 (January 8th, 2009)
123
+
124
+ * Introduced a bug in 2.2.5 in the #add_order! core ext for ActiveRecord. Fixed [Ken Collins]
125
+
126
+
127
+ * 2.2.5 (January 4th, 2009)
128
+
129
+ * Added a log_info_schema_queries class attribute and make all queries to INFORMATION_SCHEMA silent by
130
+ default. [Ken Collins]
131
+
132
+ * Fix millisecond support in datetime columns. ODBC::Timestamp incorrectly takes SQL Server milliseconds
133
+ and applies them as nanoseconds. We cope with this at the DBI layer by using SQLServerDBI::Type::SqlserverTimestamp
134
+ class to parse the before type cast value appropriately. Also update the adapters #quoted_date method
135
+ to work more simply by converting ruby's #usec milliseconds to SQL Server microseconds. [Ken Collins]
136
+
137
+ * Core extensions for ActiveRecord now reflect on the connection before doing SQL Server things. Now
138
+ this adapter is compatible for using with other adapters. [Ken Collins]
139
+
140
+
141
+ * 2.2.4 (December 5th, 2008)
142
+
143
+ * Fix a type left in #views_real_column_name. Also cache #view_information lookups. [Ken Collins]
144
+
145
+
146
+ * 2.2.3 (December 5th, 2008)
147
+
148
+ * Changing back to using real table name in column_definitions. Makes sure views get back only the columns
149
+ that are defined for them with correct names, etc. Now supporting views by looking for NULL default and
150
+ then if table name is a view, perform a targeted with sub select to the real table name and column name
151
+ to find true default. [Ken Collins]
152
+
153
+ * Ensure that add_limit_offset! does not alter sub queries. [Erik Bryn]
154
+
155
+
156
+ 2.2.2 (December 2nd, 2008)
157
+
158
+ * Add support for view defaults by making column_definitions use real table name for schema info. [Ken Collins]
159
+
160
+ * Include version in connection method and inspection. [Ken Collins]
161
+
162
+
163
+ 2.2.1 (November 25th, 2008)
164
+
165
+ * Add identity insert support for views. Cache #views so that identity #table_name_or_views_table_name
166
+ will run quickly. [Ken Collins]
167
+
168
+ * Add views support. ActiveRecord classes can use views. The connection now has a #views method and
169
+ #table_exists? will now fall back to checking views too. [Ken Collins]
170
+
171
+
172
+ 2.2.0 (November 21st, 2008)
173
+
174
+ * Release for rails 2.2.2. Many many changes. [Ken Collins], [Murray Steele], [Shawn Balestracci], [Joe Rafaniello]
175
+
@@ -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,36 @@
1
+ CHANGELOG
2
+ lib/active_record/connection_adapters/sqlserver_adapter.rb
3
+ lib/activerecord-sqlserver-adapter.rb
4
+ lib/core_ext/active_record.rb
5
+ lib/core_ext/dbi.rb
6
+ Manifest
7
+ MIT-LICENSE
8
+ Rakefile
9
+ README.rdoc
10
+ RUNNING_UNIT_TESTS
11
+ tasks/sqlserver.rake
12
+ test/cases/aaaa_create_tables_test_sqlserver.rb
13
+ test/cases/adapter_test_sqlserver.rb
14
+ test/cases/attribute_methods_test_sqlserver.rb
15
+ test/cases/basics_test_sqlserver.rb
16
+ test/cases/calculations_test_sqlserver.rb
17
+ test/cases/column_test_sqlserver.rb
18
+ test/cases/connection_test_sqlserver.rb
19
+ test/cases/eager_association_test_sqlserver.rb
20
+ test/cases/execute_procedure_test_sqlserver.rb
21
+ test/cases/inheritance_test_sqlserver.rb
22
+ test/cases/method_scoping_test_sqlserver.rb
23
+ test/cases/migration_test_sqlserver.rb
24
+ test/cases/offset_and_limit_test_sqlserver.rb
25
+ test/cases/pessimistic_locking_test_sqlserver.rb
26
+ test/cases/query_cache_test_sqlserver.rb
27
+ test/cases/schema_dumper_test_sqlserver.rb
28
+ test/cases/specific_schema_test_sqlserver.rb
29
+ test/cases/sqlserver_helper.rb
30
+ test/cases/table_name_test_sqlserver.rb
31
+ test/cases/transaction_test_sqlserver.rb
32
+ test/cases/unicode_test_sqlserver.rb
33
+ test/connections/native_sqlserver/connection.rb
34
+ test/connections/native_sqlserver_odbc/connection.rb
35
+ test/migrations/transaction_table/1_table_will_never_be_created.rb
36
+ test/schema/sqlserver_specific_schema.rb
@@ -0,0 +1,175 @@
1
+
2
+ == Rails SQL Server 2000, 2005 and 2008 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 SQL Server 2008 too!
10
+ * Fully tested under 1.9!!! Correctly encodes/decodes UTF-8 types in ruby 1.9 too.
11
+ * Now supports both rails 2.2 & 2.3!!!
12
+ * An ActiveRecord::Base.execute_procedure method that can be used by classes.
13
+ * Enabled support for DDL transactions.
14
+ * Micro second support. Time#usec is automatically converted to SQL Server's 3.33 millisecond limitation.
15
+ * Datetime data types before type casting are represented correctly. For example: 1998-01-01 23:59:59.997
16
+ * Implementation for #disable_referential_integrity used by ActiveRecord's Fixtures class.
17
+ * Pessimistic locking suppot. See the #add_lock! method for details.
18
+ * Enabled #case_sensitive_equality_operator used by unique validations.
19
+ * Unicode character support for nchar, nvarchar and ntext data types. Configuration option for defaulting all string data types to the unicode safe types.
20
+ * View support for table names, identity inserts, and column defaults.
21
+ * A block method to run queries within a specific isolation level.
22
+ * Automatically reconnects to lost database connections.
23
+
24
+
25
+ ==== SQL Server 2008 Support
26
+
27
+ Because this adapter is primarily coded to SQL Server 2000/2005, it does not take advantage of many of the things in 2008 that would speed up the code. At some point in the future there will be a branch of this code that is specifically targeted for 2008. That adapter version will remove much of the dirty innards of this version that are meant to code around many previous SQL Server 2000/2005 short comings, the biggest being no limit/offset.
28
+
29
+
30
+
31
+ ==== Date/Time Data Type Hinting
32
+
33
+ Both SQL Server 2000 and 2005 do not include 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.
34
+
35
+ class Topic < ActiveRecord::Base
36
+ coerce_sqlserver_date :last_read
37
+ coerce_sqlserver_time :bonus_time
38
+ end
39
+
40
+ 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.
41
+
42
+ ==== Executing Stored Procedures
43
+
44
+ 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.
45
+
46
+ Account.execute_procedure :update_totals, 'admin', nil, true
47
+
48
+ ==== Native Data Type Support
49
+
50
+ Currently the following custom data types have been tested for schema definitions.
51
+
52
+ * char
53
+ * nchar
54
+ * nvarchar
55
+ * ntext
56
+ * varchar(max) for SQL Server 2005 only.
57
+ * nvarchar(max) for SQL Server 2005 only.
58
+
59
+ For example:
60
+
61
+ create_table :sql_server_custom_types, :force => true do |t|
62
+ t.column :ten_code, :char, :limit => 10
63
+ t.column :ten_code_utf8, :nchar, :limit => 10
64
+ t.column :title_utf8, :nvarchar
65
+ t.column :body, :varchar_max # Creates varchar(max)
66
+ t.column :body_utf8, :ntext
67
+ t.column :body2_utf8, :nvarchar_max # Creates nvarchar(max)
68
+ end
69
+
70
+ 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.
71
+
72
+
73
+ ==== Native Text/String/Binary Data Type Accessor
74
+
75
+ 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.
76
+
77
+ * SQL Server 2000 is 'text'
78
+ * SQL Server 2005 is 'varchar(max)'
79
+
80
+ 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.
81
+
82
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'varchar(8000)'
83
+
84
+ 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.
85
+
86
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_string_database_type = 'nvarchar'
87
+
88
+ By default any :binary column created by migrations will create these native types
89
+
90
+ * SQL Server 2000 is 'image'
91
+ * SQL Server 2005 is 'varbinary(max)'
92
+
93
+
94
+ ==== Setting Unicode Types As Default
95
+
96
+ 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.
97
+
98
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.enable_default_unicode_types = true
99
+
100
+ # SQL Server 2000
101
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'ntext'
102
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_string_database_type = 'nvarchar'
103
+
104
+ # SQL Server 2005
105
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'nvarchar(max)'
106
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_string_database_type = 'nvarchar'
107
+
108
+ 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).
109
+
110
+
111
+ ==== Schema Information Logging
112
+
113
+ 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.
114
+
115
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.log_info_schema_queries = true
116
+
117
+ ==== Auto Connecting
118
+
119
+ By default the adapter will auto connect to lost DB connections. For every query it will retry at intervals of 2, 4, 8, 16 and 32 seconds. During each retry it will callback out to ActiveRecord::Base.did_retry_sqlserver_connection(connection,count). When all retries fail, it will callback to ActiveRecord::Base.did_lose_sqlserver_connection(connection). Both implementations of these methods are to write to the rails logger, however, they make great override points for notifications like Hoptoad. If you want to disable automatic reconnections use the following in an initializer.
120
+
121
+ ActiveRecord::ConnectionAdapters::SQLServerAdapter.auto_connect = false
122
+
123
+
124
+ == Versions
125
+
126
+ 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.
127
+
128
+
129
+ == Installation
130
+
131
+ First, you will need Ruby DBI and Ruby ODBC. If you are using the adapter under 1.9, then you need at least ruby-odbc version 0.9996. 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.
132
+
133
+ 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.1. Note that DBI 0.4.1 is the minimal for ruby 1.9 compatibility. Because later versions of DBI will be changing many things, IT IS HIGHLY RECOMMENDED that you max your install to version 0.4.1 which the examples below show. For the time being we are not supporting DBI versions higher than 0.4.1. 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.
134
+
135
+ $ gem install dbi --version 0.4.1
136
+ $ gem install dbd-odbc --version 0.2.4
137
+ $ gem install rails-sqlserver-2000-2005-adapter -s http://gems.github.com
138
+
139
+ Optionally configure your gem dependencies in your rails environment.rb file.
140
+
141
+ config.gem 'dbi', :version => '0.4.1'
142
+ config.gem 'dbd-odbc', :version => '0.2.4', :lib => 'dbd/ODBC'
143
+ config.gem 'rails-sqlserver-2000-2005-adapter', :source => 'http://gems.github.com'
144
+
145
+ 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.
146
+
147
+ * http://ruby-dbi.sourceforge.net/
148
+ * http://www.ch-werner.de/rubyodbc/
149
+
150
+
151
+ == Contributing
152
+
153
+ 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.
154
+
155
+ * Github: http://github.com/rails-sqlserver
156
+ * Lighthouse: http://rails-sqlserver.lighthouseapp.com/projects/20277-sql-server-05-adapter/tickets
157
+ * Google Group: http://groups.google.com/group/rails-sqlserver-adapter
158
+ * IRC Room: #rails-sqlserver on irc.freenode.net
159
+
160
+
161
+ == Credits
162
+
163
+ Many many people have contributed. If you do not see your name here and it should be let us know.
164
+
165
+ * Ken Collins
166
+ * Murray Steele
167
+ * Shawn Balestracci
168
+ * Joe Rafaniello
169
+ * Tom Ward
170
+
171
+
172
+ == License
173
+
174
+ Copyright © 2008. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
175
+
@@ -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
+