diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-08 04:37:22 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-08 04:37:22 +0000 |
commit | a90fdec0311a73ee093344650550253ecc6d28d7 (patch) | |
tree | 4ae9ee40984ebccb4d43dd1cccc381ed39ae6ccd | |
parent | 5298f730bb181fb0f34e2bc641bed3a0c5abb6dd (diff) | |
download | rails-a90fdec0311a73ee093344650550253ecc6d28d7.tar.gz rails-a90fdec0311a73ee093344650550253ecc6d28d7.tar.bz2 rails-a90fdec0311a73ee093344650550253ecc6d28d7.zip |
More compatible Oracle column reflection. Closes #2771.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2935 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/CHANGELOG | 5 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/oci_adapter.rb | 20 |
2 files changed, 18 insertions, 7 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index a15775af2a..63672ff71a 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,3 +1,8 @@ +*SVN* + +* More compatible Oracle column reflection. #2771 [Ryan Davis <ryand-ruby@zenspider.com>, Michael Schoen <schoenm@earthlink.net>] + + *1.13.0* (November 7th, 2005) * Fixed faulty regex in get_table_name method (SQLServerAdapter) #2639 [Ryan Tomayko] diff --git a/activerecord/lib/active_record/connection_adapters/oci_adapter.rb b/activerecord/lib/active_record/connection_adapters/oci_adapter.rb index 1519e1cefd..5f27fb1ca5 100644 --- a/activerecord/lib/active_record/connection_adapters/oci_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/oci_adapter.rb @@ -312,19 +312,25 @@ begin end def columns(table_name, name = nil) #:nodoc: + table_name = table_name.to_s.upcase + owner = table_name.include?('.') ? "'#{table_name.split('.').first}'" : "user" + table = "'#{table_name.split('.').last}'" + select_all(%Q{ select column_name, data_type, data_default, nullable, case when data_type = 'NUMBER' then data_precision - when data_type = 'VARCHAR2' then data_length + when data_type = 'VARCHAR2' then data_length else null end as length, case when data_type = 'NUMBER' then data_scale else null end as scale - from user_catalog cat, user_synonyms syn, all_tab_columns col - where cat.table_name = '#{table_name.to_s.upcase}' - and syn.synonym_name (+)= cat.table_name - and col.owner = nvl(syn.table_owner, user) - and col.table_name = nvl(syn.table_name, cat.table_name)} - ).map do |row| + from all_catalog cat, all_synonyms syn, all_tab_columns col + where cat.owner = #{owner} + and cat.table_name = #{table} + and syn.owner (+)= cat.owner + and syn.synonym_name (+)= cat.table_name + and col.owner = nvl(syn.table_owner, cat.owner) + and col.table_name = nvl(syn.table_name, cat.table_name) + }).map do |row| row['data_default'].gsub!(/^'(.*)'$/, '\1') if row['data_default'] OCIColumn.new( oci_downcase(row['column_name']), |