Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 2997

Show
Ignore:
Timestamp:
11/13/05 07:29:02 (3 years ago)
Author:
bitsweat
Message:

r3033@asus: jeremy | 2005-11-12 23:27:13 -0800
Apply [2996] to stable. Much faster Oracle column reflection. Closes #2848.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/stable/activerecord/CHANGELOG

    r2991 r2997  
    11*SVN* 
     2 
     3* Much faster Oracle column reflection.  #2848 [Michael Schoen <schoenm@earthlink.net>] 
    24 
    35* Base.reset_sequence_name analogous to reset_table_name (mostly useful for testing).  Base.define_attr_method allows nil values.  [Jeremy Kemper] 
  • branches/stable/activerecord/lib/active_record/connection_adapters/oci_adapter.rb

    r2966 r2997  
    317317          owner = table_name.include?('.') ? "'#{table_name.split('.').first}'" : "user" 
    318318          table = "'#{table_name.split('.').last}'" 
    319  
    320           select_all(%Q{ 
    321               select column_name, data_type, data_default, nullable, 
    322                      case when data_type = 'NUMBER' then data_precision 
    323                           when data_type = 'VARCHAR2' then data_length 
    324                           else null end as length, 
    325                      case when data_type = 'NUMBER' then data_scale 
    326                           else null end as scale 
    327                from all_catalog cat, all_synonyms syn, all_tab_columns col 
    328               where cat.owner = #{owner} 
    329                 and cat.table_name = #{table} 
    330                 and syn.owner (+)= cat.owner 
    331                 and syn.synonym_name (+)= cat.table_name 
    332                 and col.owner = nvl(syn.table_owner, cat.owner) 
    333                 and col.table_name = nvl(syn.table_name, cat.table_name) 
    334           }).map do |row| 
    335             row['data_default'].gsub!(/^'(.*)'\s*$/, '\1') if row['data_default'] 
     319          scope = (owner == "user" ? "user" : "all") 
     320 
     321          table_cols = %Q{ 
     322            select column_name, data_type, data_default, nullable, 
     323                   case when data_type = 'NUMBER' then data_precision 
     324                        when data_type = 'VARCHAR2' then data_length 
     325                        else null end as length, 
     326                   case when data_type = 'NUMBER' then data_scale 
     327                        else null end as scale 
     328              from #{scope}_catalog cat, #{scope}_synonyms syn, all_tab_columns col 
     329             where cat.table_name = #{table} 
     330               and syn.synonym_name (+)= cat.table_name 
     331               and col.table_name = nvl(syn.table_name, cat.table_name) 
     332               and col.owner = nvl(syn.table_owner, #{(scope == "all" ? "cat.owner" : "user")}) } 
     333 
     334          if scope == "all" 
     335            table_cols << %Q{ 
     336               and cat.owner = #{owner} 
     337               and syn.owner (+)= cat.owner } 
     338          end 
     339 
     340          select_all(table_cols).map do |row| 
     341            row['data_default'].gsub!(/^'(.*)'$/, '\1') if row['data_default'] 
    336342            OCIColumn.new( 
    337343              oci_downcase(row['column_name']),