Sha256: cb2ec9321bad23e3df52f2c5ffdf62f5585c2376224af2868f07265ed6f7859e
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
class Baza::Driver::Mysql::Indexes def initialize(args) @args = args end end class Baza::Driver::Mysql::Indexes::Index attr_reader :args, :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 rename newname newname = newname.to_sym create_args = data create_args[:name] = newname drop table.create_indexes([create_args]) @args[:data][:Key_name] = newname 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 #Returns true if the index is a primary-index. def primary? return true if @args[:data][:Key_name] == "PRIMARY" return false end def to_s return "#<Baza::Driver::Mysql::Index name: \"#{name}\", columns: #{@columns}, primary: #{primary?}, unique: #{unique?}>" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
baza-0.0.14 | include/drivers/mysql/mysql_indexes.rb |