Skip to content

Commit

Permalink
Fixed that SQL Server should ignore :size declarations on anything bu…
Browse files Browse the repository at this point in the history
…t integer and string in the agnostic schema representation (closes #2756) [Ryan Tomayko]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2887 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Nov 6, 2005
1 parent c7da7a3 commit 6c55727
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def native_database_types
: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" },
Expand Down Expand Up @@ -414,6 +414,15 @@ def remove_index(table_name, options = {})
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 = []
Expand Down

0 comments on commit 6c55727

Please sign in to comment.