Browse files

Merge [5944] from trunk. References #7048.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5945 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent aa30fc7 commit 5d0fd52305e371c3ace085b8e1cac71ef6c14ede @jeremy jeremy committed Jan 15, 2007
View
2 activerecord/CHANGELOG
@@ -1,6 +1,6 @@
*SVN*
-* change_column accepts :default => nil. #6956 [dcmanges, Jeremy Kemper]
+* change_column accepts :default => nil. Skip column options for primary keys. #6956, #7048 [dcmanges, Jeremy Kemper]
* MySQL, PostgreSQL: change_column_default quotes the default value and doesn't lose column type information. #3987, #6664 [Jonathan Viney, manfred, altano@bigfoot.com]
View
14 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -203,17 +203,19 @@ class IndexDefinition < Struct.new(:table, :name, :unique, :columns) #:nodoc:
end
class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :precision, :scale, :default, :null) #:nodoc:
+
+ def sql_type
+ base.type_to_sql(type.to_sym, limit, precision, scale) rescue type
+ end
+
def to_sql
- column_sql = "#{base.quote_column_name(name)} #{type_to_sql(type.to_sym, limit, precision, scale)}"
- add_column_options!(column_sql, :null => null, :default => default)
+ column_sql = "#{base.quote_column_name(name)} #{sql_type}"
+ add_column_options!(column_sql, :null => null, :default => default) unless type.to_sym == :primary_key
column_sql
end
alias to_s :to_sql
private
- def type_to_sql(name, limit, precision, scale)
- base.type_to_sql(name, limit, precision, scale) rescue name
- end
def add_column_options!(sql, options)
base.add_column_options!(sql, options.merge(:column => self))
@@ -233,7 +235,7 @@ def initialize(base)
# Appends a primary key definition to the table definition.
# Can be called multiple times, but this is probably not a good idea.
def primary_key(name)
- column(name, native[:primary_key])
+ column(name, :primary_key)
end
# Returns a ColumnDefinition for the column with name +name+.
View
2 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -254,7 +254,7 @@ def dump_schema_information #:nodoc:
def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
native = native_database_types[type]
- column_type_sql = native[:name]
+ column_type_sql = native.is_a?(Hash) ? native[:name] : native
if type == :decimal # ignore limit, use precison and scale
precision ||= native[:precision]
scale ||= native[:scale]
View
2 activerecord/lib/active_record/connection_adapters/oracle_adapter.rb
@@ -172,7 +172,7 @@ def quote_string(s) #:nodoc:
def quote(value, column = nil) #:nodoc:
if column && [:text, :binary].include?(column.type)
- %Q{empty_#{ column.sql_type rescue 'blob' }()}
+ %Q{empty_#{ column.sql_type.downcase rescue 'blob' }()}
else
super
end

0 comments on commit 5d0fd52

Please sign in to comment.