lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_tables.rb in knjrbfw-0.0.27 vs lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_tables.rb in knjrbfw-0.0.28

- old
+ new

@@ -4,11 +4,10 @@ attr_reader :db, :driver def initialize(args) @args = args @db = @args[:db] - @driver = @args[:driver] @list_mutex = Mutex.new @list = Knj::Wref_map.new end @@ -36,11 +35,10 @@ obj = @list.get!(d_tables[:name]) if !obj obj = KnjDB_sqlite3::Tables::Table.new( :db => @db, - :driver => @driver, :data => d_tables ) @list[d_tables[:name]] = obj end @@ -81,11 +79,10 @@ end class KnjDB_sqlite3::Tables::Table def initialize(args) @db = args[:db] - @driver = args[:driver] @data = args[:data] @list = Knj::Wref_map.new @indexes_list = Knj::Wref_map.new end @@ -115,18 +112,17 @@ def columns @db.cols ret = {} - @db.q("PRAGMA table_info(`#{@driver.esc_table(self.name)}`)") do |d_cols| + @db.q("PRAGMA table_info(`#{@db.esc_table(self.name)}`)") do |d_cols| obj = @list.get!(d_cols[:name]) if !obj obj = KnjDB_sqlite3::Columns::Column.new( :table_name => self.name, :db => @db, - :driver => @driver, :data => d_cols ) @list[d_cols[:name]] = obj end @@ -292,13 +288,13 @@ raise Knj::Errors::NotFound.new("Index not found: #{name}.") end def indexes @db.indexes - ret = {} + ret = {} unless block_given? - @db.q("PRAGMA index_list(`#{@driver.esc_table(self.name)}`)") do |d_indexes| + @db.q("PRAGMA index_list(`#{@db.esc_table(self.name)}`)") do |d_indexes| next if d_indexes[:Key_name] == "PRIMARY" obj = @indexes_list.get!(d_indexes[:name]) if !obj @@ -315,11 +311,10 @@ end obj = KnjDB_sqlite3::Indexes::Index.new( :table_name => self.name, :db => @db, - :driver => @driver, :data => d_indexes ) obj.columns << name @indexes_list[d_indexes[:name]] = obj end @@ -376,7 +371,11 @@ indexes.each do |name, index| ret["indexes"] << index.data if name != "PRIMARY" end return ret + end + + def insert(data) + @db.insert(self.name, data) end end \ No newline at end of file