Sha256: 2da46fe20464f50c6918f709b2230283bf80c3d282285f1f2b78eeccc75db79f

Contents?: true

Size: 1.1 KB

Versions: 73

Compression:

Stored size: 1.1 KB

Contents

class KnjDB_mysql::Indexes
  def initialize(args)
    @args = args
  end
end

class KnjDB_mysql::Indexes::Index
  attr_reader :columns
  
  def initialize(args)
    @args = args
    @columns = []
  end
  
  #Used to validate in Knj::Wrap_map.
  def __object_unique_id__
    return @args[:data][:Key_name]
  end
  
  def name
    return @args[:data][:Key_name]
  end
  
  def table
    return @args[:db].tables[@args[:table_name]]
  end
  
  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.message.index("check that column/key exists") != nil
        #ignore.
      else
        raise e
      end
    end
  end
  
  def data
    return {
      "name" => name,
      "columns" => @columns
    }
  end
  
  #Returns true if the index is a unique-index.
  def unique?
    if @args[:data][:Index_type] == "UNIQUE"
      return true
    else
      return false
    end
  end
  
  #Inspect crashes if this is not present? - knj.
  def to_s
    return "#<#{self.class.name}>"
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
knjrbfw-0.0.101 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.100 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.99 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.98 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.97 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.96 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.95 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.94 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.93 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.92 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.91 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.90 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.89 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.88 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.87 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.86 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.85 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.84 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.83 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.82 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb