aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb11
2 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 0c15716116..d13d06585c 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that SQL Server should ignore :size declarations on anything but integer and string in the agnostic schema representation #2756 [Ryan Tomayko]
+
* Added constrain scoping for creates using a hash of attributes bound to the :creation key [DHH]. Example:
Comment.constrain(:creation => { :post_id => 5 }) do
diff --git a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
index fa9ec97794..a1b424f260 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -175,7 +175,7 @@ module ActiveRecord
:primary_key => "int NOT NULL IDENTITY(1, 1) PRIMARY KEY",
:string => { :name => "varchar", :limit => 255 },
:text => { :name => "text" },
- :integer => { :name => "int"},
+ :integer => { :name => "int" },
:float => { :name => "float", :limit => 8 },
:datetime => { :name => "datetime" },
:timestamp => { :name => "datetime" },
@@ -414,6 +414,15 @@ module ActiveRecord
execute "DROP INDEX #{table_name}.#{index_name(table_name, options)}"
end
+ def type_to_sql(type, limit = nil) #:nodoc:
+ native = native_database_types[type]
+ # if there's no :limit in the default type definition, assume that type doesn't support limits
+ limit = native[:limit] ? limit || native[:limit] : nil
+ column_type_sql = native[:name]
+ column_type_sql << "(#{limit})" if limit
+ column_type_sql
+ end
+
private
def select(sql, name = nil)
rows = []