Class: Rubeus::Jdbc::PrimaryKey

Inherits:
TableElement show all
Includes:
FullyQualifiedNamed
Defined in:
lib/rubeus/jdbc/primary_key.rb

Constant Summary

Constants included from FullyQualifiedNamed

FullyQualifiedNamed::FQN_ATTRS, FullyQualifiedNamed::FQN_ATTR_STRS

Instance Attribute Summary collapse

Attributes inherited from TableElement

#table

Attributes inherited from MetaElement

#jdbc_info, #meta_data, #options

Instance Method Summary collapse

Methods included from FullyQualifiedNamed

#fully_qualified_name, #same_fqn?

Methods inherited from TableElement

#initialize, #pretty_print_instance_variables

Methods inherited from MetaElement

#initialize, #pretty_print_instance_variables

Constructor Details

This class inherits a constructor from Rubeus::Jdbc::TableElement

Instance Attribute Details

#column_namesObject

  1. TABLE_CAT String => テーブルカタログ (null の可能性がある)

  2. TABLE_SCHEM String => テーブルスキーマ (null の可能性がある)

  3. TABLE_NAME String => テーブル名

  4. COLUMN_NAME String => 列名

  5. KEY_SEQ short => 主キー中の連番

  6. PK_NAME String => 主キー名 (null の可能性がある)

see also: java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/sql/DatabaseMetaData.html#getPrimaryKeys(java.lang.String,%20java.lang.String,%20java.lang.String)



17
18
19
# File 'lib/rubeus/jdbc/primary_key.rb', line 17

def column_names
  @column_names
end

#pk_nameObject

  1. TABLE_CAT String => テーブルカタログ (null の可能性がある)

  2. TABLE_SCHEM String => テーブルスキーマ (null の可能性がある)

  3. TABLE_NAME String => テーブル名

  4. COLUMN_NAME String => 列名

  5. KEY_SEQ short => 主キー中の連番

  6. PK_NAME String => 主キー名 (null の可能性がある)

see also: java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/sql/DatabaseMetaData.html#getPrimaryKeys(java.lang.String,%20java.lang.String,%20java.lang.String)



17
18
19
# File 'lib/rubeus/jdbc/primary_key.rb', line 17

def pk_name
  @pk_name
end

Instance Method Details

#[](index) ⇒ Object



26
27
28
# File 'lib/rubeus/jdbc/primary_key.rb', line 26

def [](index)
  column_names[index]
end

#columnsObject



38
39
40
41
# File 'lib/rubeus/jdbc/primary_key.rb', line 38

def columns
  @columns ||= Rubeus::Util::NameAccessArray.new(*
    column_names.map{|col_name| table.columns[col_name]})
end

#inspectObject

attr_accessor :key_seq # key_seq はこのインスタンス生成時のcolumn_namesの要素の順番として保持されます。 alias_method :seq, :key_seq



22
23
24
# File 'lib/rubeus/jdbc/primary_key.rb', line 22

def inspect
  "#<#{self.class.name} #{table.name}(%s)>" % column_names.join(',')
end

#lengthObject



30
31
32
# File 'lib/rubeus/jdbc/primary_key.rb', line 30

def length
  column_names.length
end

#nameObject



34
35
36
# File 'lib/rubeus/jdbc/primary_key.rb', line 34

def name
  column_names.send(options[:name_case] || :to_s).join(",")
end