Oracle adapter gets some love #4230 [schoenm@earthlink.net]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3889 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
275ea6de49
commit
9b9a0908e5
|
@ -1,5 +1,13 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Oracle adapter gets some love #4230 [schoenm@earthlink.net]
|
||||||
|
|
||||||
|
* Changes :text to CLOB rather than BLOB [Moses Hohman]
|
||||||
|
* Fixes an issue with nil numeric length/scales (several)
|
||||||
|
* Implements support for XMLTYPE columns [wilig / Kubo Takehiro]
|
||||||
|
* Tweaks a unit test to get it all green again
|
||||||
|
* Adds support for #current_database
|
||||||
|
|
||||||
* Added Base.abstract_class? that marks which classes are not part of the Active Record hierarchy #3704 [Rick Olson]
|
* Added Base.abstract_class? that marks which classes are not part of the Active Record hierarchy #3704 [Rick Olson]
|
||||||
|
|
||||||
class CachedModel < ActiveRecord::Base
|
class CachedModel < ActiveRecord::Base
|
||||||
|
|
|
@ -108,7 +108,8 @@ begin
|
||||||
when /char/i : :string
|
when /char/i : :string
|
||||||
when /num|float|double|dec|real|int/i : @scale == 0 ? :integer : :float
|
when /num|float|double|dec|real|int/i : @scale == 0 ? :integer : :float
|
||||||
when /date|time/i : @name =~ /_at$/ ? :time : :datetime
|
when /date|time/i : @name =~ /_at$/ ? :time : :datetime
|
||||||
when /lob/i : :binary
|
when /clob/i : :text
|
||||||
|
when /blob/i : :binary
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -178,7 +179,7 @@ begin
|
||||||
{
|
{
|
||||||
:primary_key => "NUMBER(38) NOT NULL PRIMARY KEY",
|
:primary_key => "NUMBER(38) NOT NULL PRIMARY KEY",
|
||||||
:string => { :name => "VARCHAR2", :limit => 255 },
|
:string => { :name => "VARCHAR2", :limit => 255 },
|
||||||
:text => { :name => "BLOB" },
|
:text => { :name => "CLOB" },
|
||||||
:integer => { :name => "NUMBER", :limit => 38 },
|
:integer => { :name => "NUMBER", :limit => 38 },
|
||||||
:float => { :name => "NUMBER" },
|
:float => { :name => "NUMBER" },
|
||||||
:datetime => { :name => "DATE" },
|
:datetime => { :name => "DATE" },
|
||||||
|
@ -316,6 +317,10 @@ begin
|
||||||
#
|
#
|
||||||
# see: abstract/schema_statements.rb
|
# see: abstract/schema_statements.rb
|
||||||
|
|
||||||
|
def current_database #:nodoc:
|
||||||
|
select_one("select sys_context('userenv','db_name') db from dual")["db"]
|
||||||
|
end
|
||||||
|
|
||||||
def tables(name = nil) #:nodoc:
|
def tables(name = nil) #:nodoc:
|
||||||
select_all("select lower(table_name) from user_tables").inject([]) do | tabs, t |
|
select_all("select lower(table_name) from user_tables").inject([]) do | tabs, t |
|
||||||
tabs << t.to_a.first.last
|
tabs << t.to_a.first.last
|
||||||
|
@ -368,8 +373,8 @@ begin
|
||||||
oracle_downcase(row['column_name']),
|
oracle_downcase(row['column_name']),
|
||||||
row['data_default'],
|
row['data_default'],
|
||||||
row['data_type'],
|
row['data_type'],
|
||||||
row['length'].to_i,
|
(l = row['length']).nil? ? nil : l.to_i,
|
||||||
row['scale'].to_i,
|
(s = row['scale']).nil? ? nil : s.to_i,
|
||||||
row['nullable'] == 'Y'
|
row['nullable'] == 'Y'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -509,6 +514,12 @@ begin
|
||||||
case do_ocicall(@ctx) { @parms[i - 1].attrGet(OCI_ATTR_DATA_TYPE) }
|
case do_ocicall(@ctx) { @parms[i - 1].attrGet(OCI_ATTR_DATA_TYPE) }
|
||||||
when 8 : @stmt.defineByPos(i, String, 65535) # Read LONG values
|
when 8 : @stmt.defineByPos(i, String, 65535) # Read LONG values
|
||||||
when 187 : @stmt.defineByPos(i, OraDate) # Read TIMESTAMP values
|
when 187 : @stmt.defineByPos(i, OraDate) # Read TIMESTAMP values
|
||||||
|
when 108
|
||||||
|
if @parms[i - 1].attrGet(OCI_ATTR_TYPE_NAME) == 'XMLTYPE'
|
||||||
|
@stmt.defineByPos(i, String, 65535)
|
||||||
|
else
|
||||||
|
raise 'unsupported datatype'
|
||||||
|
end
|
||||||
else define_a_column_pre_ar i
|
else define_a_column_pre_ar i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1172,14 +1172,17 @@ class BasicsTest < Test::Unit::TestCase
|
||||||
assert xml.include?(%(<title>The First Topic</title>))
|
assert xml.include?(%(<title>The First Topic</title>))
|
||||||
assert xml.include?(%(<author-name>David</author-name>))
|
assert xml.include?(%(<author-name>David</author-name>))
|
||||||
assert xml.include?(%(<id type="integer">1</id>))
|
assert xml.include?(%(<id type="integer">1</id>))
|
||||||
assert xml.include?(%(<approved type="boolean">false</approved>)), "Approved should be a boolean"
|
|
||||||
assert xml.include?(%(<replies-count type="integer">0</replies-count>))
|
assert xml.include?(%(<replies-count type="integer">0</replies-count>))
|
||||||
assert xml.include?(%(<bonus-time type="datetime">#{bonus_time_in_current_timezone}</bonus-time>))
|
|
||||||
assert xml.include?(%(<written-on type="datetime">#{written_on_in_current_timezone}</written-on>))
|
assert xml.include?(%(<written-on type="datetime">#{written_on_in_current_timezone}</written-on>))
|
||||||
assert xml.include?(%(<content>Have a nice day</content>))
|
assert xml.include?(%(<content>Have a nice day</content>))
|
||||||
assert xml.include?(%(<author-email-address>david@loudthinking.com</author-email-address>))
|
assert xml.include?(%(<author-email-address>david@loudthinking.com</author-email-address>))
|
||||||
assert xml.include?(%(<parent-id></parent-id>))
|
assert xml.include?(%(<parent-id></parent-id>))
|
||||||
assert xml.include?(%(<last-read type="date">2004-04-15</last-read>))
|
assert xml.include?(%(<last-read type="date">2004-04-15</last-read>))
|
||||||
|
# Oracle doesn't have true boolean or time-only fields
|
||||||
|
unless current_adapter?(:OracleAdapter)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_xml_skipping_attributes
|
def test_to_xml_skipping_attributes
|
||||||
|
|
Loading…
Reference in New Issue