Module: Sequel::Oracle::DatabaseExtensions

Defined in:
lib/sequel/oracle_extensions/schemata.rb

Overview

Methods that override existing functionality on Sequel::Oracle::Database.

Instance Method Summary collapse

Instance Method Details

#schema_parse_table(table, opts = {}) ⇒ Object

Overridden to collect additional table-level information from the metadata.

See Sequel::Oracle::Database#schema_parse_table for the original implementation.



515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/sequel/oracle_extensions/schemata.rb', line 515

def schema_parse_table(table, opts={})
  ds = dataset
  ds.identifier_output_method = :downcase
  schema_and_table = "#{"#{quote_identifier(opts[:schema])}." if opts[:schema]}#{quote_identifier(table)}"
  table_schema = []
   = transaction(opts){|conn| conn.describe_table(schema_and_table)}
  .columns.each do |column|
    table_schema << [
      column.name.downcase.to_sym,
      {
        :type => column.data_type,
        :db_type => column.type_string.split(' ')[0],
        :type_string => column.type_string,
        :charset_form => column.charset_form,
        :char_used => column.char_used?,
        :char_size => column.char_size,
        :data_size => column.data_size,
        :precision => column.precision,
        :scale => column.scale,
        :fsprecision => column.fsprecision,
        :lfprecision => column.lfprecision,
        :allow_null => column.nullable?
      }
    ]
  end
  table_schema.instance_variable_set :@features, {
    :owner         => :"#{.obj_schema.downcase}",
    :clustered     => (.clustered? rescue nil),
    :temporary     => (.is_temporary? rescue nil),
    :partitioning  => (.partitioned? rescue nil),
    :typed         => (.is_typed? rescue nil),
    :index_only    => (.index_only? rescue nil)
  }
  table_schema
end