class Coopy::SqlTable
Attributes
cache[RW]
column_names[RW]
columns[RW]
db[RW]
h[RW]
helper[RW]
id2rid[RW]
name[RW]
quoted_table_name[RW]
Public Class Methods
new(db,name,helper = nil)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 7 def initialize(db,name,helper = nil) @db = db @name = name @helper = helper @helper = db.get_helper if helper == nil @cache = {} @h = -1 @id2rid = nil self.get_columns end
Public Instance Methods
alter_columns(columns)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 221 def alter_columns(columns) result = @helper.alter_columns(@db,@name,columns) @columns = nil result end
apply_flags(flags)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 276 def apply_flags(flags) false end
as_table()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 242 def as_table pct = 3 self.get_columns w = @column_names.length mt = ::Coopy::SimpleTable.new(w + 1,pct) mt.set_cell(0,0,"@") mt.set_cell(0,1,"type") mt.set_cell(0,2,"key") begin _g = 0 while(_g < w) x = _g _g+=1 i = x + 1 mt.set_cell(i,0,@column_names[x]) mt.set_cell(i,1,@columns[x].type_value) mt.set_cell(i,2,((@columns[x].primary) ? "primary" : "")) end end mt end
change_row(rc)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 227 def change_row(rc) if @helper == nil puts "No sql helper" return false end if rc.action == "+++" return @helper.insert(@db,@name,rc.val) elsif rc.action == "---" return @helper._delete(@db,@name,rc.cond) elsif rc.action == "->" return @helper.update(@db,@name,rc.cond,rc.val) end false end
clear()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 175 def clear end
clone()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 209 def clone nil end
clone_meta(table = nil)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 272 def clone_meta(table = nil) nil end
create()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 213 def create nil end
fetch_columns()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 323 def fetch_columns self.get_columns @column_names end
fetch_row()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 298 def fetch_row if @db.read row = {} begin _g1 = 0 _g = @column_names.length while(_g1 < _g) i = _g1 _g1+=1 begin v = @db.get(i) begin value = v row[@column_names[i]] = value end v end end end return row end @db._end nil end
get_all_but_primary_key()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 64 def get_all_but_primary_key self.get_columns result = Array.new begin _g = 0 _g1 = @columns while(_g < _g1.length) col = _g1[_g] _g+=1 next if col.is_primary_key result.push(col.get_name) end end result end
get_cell(x,y)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 95 def get_cell(x,y) if @h >= 0 y = y - 1 y = @id2rid[y] if y >= 0 elsif y == 0 y = -1 end if y < 0 self.get_columns return @columns[x].name end row = @cache[y] if row == nil row = {} self.get_columns @db.begin_row(@name,y,@column_names) while(@db.read) _g1 = 0 _g = self.get_width while(_g1 < _g) i = _g1 _g1+=1 begin v = @db.get(i) begin value = v row[i] = value end v end end end @db._end begin @cache[y] = row row end end begin this1 = @cache[y] this1.get(x) end end
get_cell_view()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 163 def get_cell_view ::Coopy::SimpleView.new end
get_column_names()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 80 def get_column_names self.get_columns @column_names end
get_data()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 205 def get_data nil end
get_database()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 280 def get_database @db end
get_height()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 200 def get_height return @h if @h >= 0 -1 end
get_meta()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 217 def get_meta self end
get_name()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 328 def get_name @name.to_s end
get_primary_key()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 48 def get_primary_key self.get_columns result = Array.new begin _g = 0 _g1 = @columns while(_g < _g1.length) col = _g1[_g] _g+=1 next if !col.is_primary_key result.push(col.get_name) end end result end
get_quoted_column_name(name)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 91 def get_quoted_column_name(name) @db.get_quoted_column_name(name) end
get_quoted_table_name()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 85 def get_quoted_table_name return @quoted_table_name if @quoted_table_name != nil @quoted_table_name = @db.get_quoted_table_name(@name) @quoted_table_name end
get_row_stream()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 284 def get_row_stream self.get_columns @db._begin("SELECT * FROM " + _hx_str(self.get_quoted_table_name) + " ORDER BY ?",[@db.rowid],@column_names) self end
get_width()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 195 def get_width self.get_columns @columns.length end
height()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 190 def height() get_height end
height=(__v)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 191 def height=(__v) @height = __v end
insert_or_delete_columns(fate,wfate)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 182 def insert_or_delete_columns(fate,wfate) false end
insert_or_delete_rows(fate,hfate)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 178 def insert_or_delete_rows(fate,hfate) false end
is_nested()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 290 def is_nested false end
is_resizable()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 167 def is_resizable false end
is_sql()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 294 def is_sql true end
resize(w,h)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 171 def resize(w,h) false end
set_cell(x,y,c)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 159 def set_cell(x,y,c) puts "SqlTable cannot set cells yet" end
set_cell_cache(x,y,c)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 139 def set_cell_cache(x,y,c) row = @cache[y] if row == nil row = {} self.get_columns begin @cache[y] = row row end end begin v = c begin value = v row[x] = value end v end end
trim_blank()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 186 def trim_blank false end
use_for_column_changes()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 264 def use_for_column_changes true end
use_for_row_changes()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 268 def use_for_row_changes true end
width()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 192 def width() get_width end
width=(__v)
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 193 def width=(__v) @width = __v end
Protected Instance Methods
get_columns()
click to toggle source
# File lib/lib/coopy/sql_table.rb, line 30 def get_columns return if @columns != nil return if @db == nil @columns = @db.get_columns(@name) @column_names = Array.new begin _g = 0 _g1 = @columns while(_g < _g1.length) col = _g1[_g] _g+=1 @column_names.push(col.get_name) end end end