class Baza::Driver::Sqlite3::Index
Attributes
args[R]
columns[R]
Public Class Methods
new(args)
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 4 def initialize(args) @args = args @data = args.delete(:data) @columns = [] @db = args[:db] end
Public Instance Methods
column_names()
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 46 def column_names @columns end
data()
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 38 def data { name: name, unique: unique?, columns: @columns } end
drop()
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 23 def drop @db.query("DROP INDEX `#{name}`") end
name()
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 11 def name @data.fetch(:name) end
reload()
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 54 def reload data = nil @db.query("PRAGMA index_list(#{@db.quote_table(name)})") do |d_indexes| next unless d_indexes.fetch(:name) == name data = d_indexes break end raise Baza::Errors::IndexNotFound unless data @data = data self end
rename(newname)
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 27 def rename(newname) newname = newname.to_sym create_args = data create_args[:name] = newname drop table.create_indexes([create_args]) @data[:name] = newname end
table()
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 19 def table @db.tables[table_name] end
table_name()
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 15 def table_name @args.fetch(:table_name) end
unique?()
click to toggle source
# File lib/baza/driver/sqlite3/index.rb, line 50 def unique? @data.fetch(:unique).to_i == 1 end