Permalink
Browse files

Fixed DB2 adapter so nullable columns will be determines correctly no…

…w and quotes from column default values will be removed (closes #4350) [contact@maik-schmidt.de]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4013 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent f46eb2a commit 2d24bed3a072aac1a0087ec4c4681889e49ea6a4 @dhh dhh committed Mar 22, 2006
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed DB2 adapter so nullable columns will be determines correctly now and quotes from column default values will be removed #4350 [contact@maik-schmidt.de]
+
* Allow overriding of find parameters in scoped has_many :through calls [Rick Olson]
In this example, :include => false disables the default eager association from loading. :select changes the standard
@@ -146,17 +146,18 @@ def columns(table_name, name = nil)
stmt.columns(table_name, schema).each do |c|
c_name = c[3].downcase
c_default = c[12] == 'NULL' ? nil : c[12]
+ c_default.gsub!(/^'(.*)'$/, '\1') if !c_default.nil?
c_type = c[5].downcase
c_type += "(#{c[6]})" if !c[6].nil? && c[6] != ''
- result << Column.new(c_name, c_default, c_type)
+ result << Column.new(c_name, c_default, c_type, c[17] == 'YES')
end
end
result
end
def native_database_types
{
- :primary_key => 'int generated by default as identity primary key',
+ :primary_key => 'int generated by default as identity (start with 42) primary key',
:string => { :name => 'varchar', :limit => 255 },
:text => { :name => 'clob', :limit => 32768 },
:integer => { :name => 'int' },
@@ -1190,8 +1190,8 @@ def test_to_xml
else
assert xml.include?(%(<last-read type="date">2004-04-15</last-read>))
end
- # Oracle doesn't have true boolean or time-only fields
- unless current_adapter?(:OracleAdapter)
+ # Oracle and DB2 don't have true boolean or time-only fields
+ unless current_adapter?(:OracleAdapter) || current_adapter?(:DB2Adapter)
assert xml.include?(%(<approved type="boolean">false</approved>)), "Approved should be a boolean"
assert xml.include?(%(<bonus-time type="datetime">#{bonus_time_in_current_timezone}</bonus-time>))
end

0 comments on commit 2d24bed

Please sign in to comment.