Title: [727] trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb: fixed mssql test_create_table_with_limits rails test by extending type_to_sql method to handle different types of integers
- Revision
- 727
- Author
- weijielin
- Date
- 2007-08-29 16:44:01 -0400 (Wed, 29 Aug 2007)
Log Message
fixed mssql test_create_table_with_limits rails test by extending type_to_sql method to handle different types of integers
Modified Paths
Diff
Modified: trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb (726 => 727)
--- trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb 2007-08-28 23:45:52 UTC (rev 726)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb 2007-08-29 20:44:01 UTC (rev 727)
@@ -184,9 +184,23 @@
def rename_column(table, column, new_column_name)
execute "EXEC sp_rename '#{table}.#{column}', '#{new_column_name}'"
end
-
+
+ def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
+ return super unless type.to_s == 'integer'
+
+ if limit.nil? || limit == 4
+ 'int'
+ elsif limit == 2
+ 'smallint'
+ elsif limit ==1
+ 'tinyint'
+ else
+ 'bigint'
+ end
+ end
+
def change_column(table_name, column_name, type, options = {}) #:nodoc:
- sql_commands = ["ALTER TABLE #{table_name} ALTER COLUMN #{column_name} #{type_to_sql(type, options[:limit])}"]
+ sql_commands = ["ALTER TABLE #{table_name} ALTER COLUMN #{column_name} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"]
if options_include_default?(options)
remove_default_constraint(table_name, column_name)
sql_commands << "ALTER TABLE #{table_name} ADD CONSTRAINT DF_#{table_name}_#{column_name} DEFAULT #{quote(options[:default], options[:column])} FOR #{column_name}"
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel