You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rdoc
+23-18Lines changed: 23 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,34 +6,39 @@ The SQL Server adapter for rails is back for ActiveRecord 2.2 and up! We are cur
6
6
7
7
== What's New
8
8
9
-
* Enabled support for DDL transactions.
10
-
* Micro second support. Time#usec is automatically converted to SQL Server's 3.33 millisecond limitation.
11
-
* Datetime data type before type casting are represented correctly. For example: 1998-01-01 23:59:59.997
12
-
* Implementation for #disable_referential_integrity used by ActiveRecord::Fixtures class.
13
-
* Pessimistic locking suppot. See the #add_lock! method for details.
14
-
* Enabled #case_sensitive_equality_operator used by unique validations.
15
-
* Unicode character support for nchar, nvarchar and ntext date types.
9
+
* Enabled support for DDL transactions.
10
+
* Micro second support. Time#usec is automatically converted to SQL Server's 3.33 millisecond limitation.
11
+
* Datetime data types before type casting are represented correctly. For example: 1998-01-01 23:59:59.997
12
+
* Implementation for #disable_referential_integrity used by ActiveRecord::Fixtures class.
13
+
* Pessimistic locking suppot. See the #add_lock! method for details.
14
+
* Enabled #case_sensitive_equality_operator used by unique validations.
15
+
* Unicode character support for nchar, nvarchar and ntext data types.
16
16
17
+
==== Native Text Data Type Accessor
17
18
19
+
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.
18
20
19
-
==== Native Text Datetype Accessor
21
+
* SQL Server 2000 is 'text'
22
+
* SQL Server 2005 is 'varchar(max)'
20
23
21
-
native_text_database_type
24
+
During testing this type is set to 'varchar(8000)' for both versions. 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 include this line in your environment.rb file.
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.
28
31
29
32
class Topic < ActiveRecord::Base
30
33
coerce_sqlserver_date :last_read
31
34
coerce_sqlserver_time :bonus_time
32
35
end
33
36
37
+
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.
38
+
34
39
35
40
== Installation
36
-
41
+
37
42
This method is unconfirmed. You can install the adapter as a gem using the following command. Once I confirm this I can give you an example of a config.gem command too. For now I know that rails and/or ActiveRecord expects to find the SQL Server adapter in the vendor/plugins/adapters/sqlserver folder of your rails project.
0 commit comments