Class: KnjDB_mysql::Indexes::Index
- Defined in:
- lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
Instance Method Summary collapse
-
#__object_unique_id__ ⇒ Object
Used to validate in Knj::Wrap_map.
- #data ⇒ Object
- #drop ⇒ Object
-
#initialize(args) ⇒ Index
constructor
A new instance of Index.
- #name ⇒ Object
- #table ⇒ Object
-
#to_s ⇒ Object
Inspect crashes if this is not present? - knj.
-
#unique? ⇒ Boolean
Returns true if the index is a unique-index.
Constructor Details
#initialize(args) ⇒ Index
Returns a new instance of Index.
10 11 12 13 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 10 def initialize(args) @args = args @columns = [] end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
8 9 10 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 8 def columns @columns end |
Instance Method Details
#__object_unique_id__ ⇒ Object
Used to validate in Knj::Wrap_map.
16 17 18 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 16 def __object_unique_id__ return @args[:data][:Key_name] end |
#data ⇒ Object
43 44 45 46 47 48 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 43 def data return { "name" => name, "columns" => @columns } end |
#drop ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 28 def drop sql = "DROP INDEX `#{self.name}` ON `#{self.table.name}`" begin @args[:db].query(sql) rescue => e #The index has already been dropped - ignore. if e..index("check that column/key exists") != nil #ignore. else raise e end end end |
#name ⇒ Object
20 21 22 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 20 def name return @args[:data][:Key_name] end |
#table ⇒ Object
24 25 26 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 24 def table return @args[:db].tables[@args[:table_name]] end |
#to_s ⇒ Object
Inspect crashes if this is not present? - knj.
60 61 62 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 60 def to_s return "#<#{self.class.name}>" end |
#unique? ⇒ Boolean
Returns true if the index is a unique-index.
51 52 53 54 55 56 57 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 51 def unique? if @args[:data][:Index_type] == "UNIQUE" return true else return false end end |