Ejemplo n.º 1
0
func initTables() {
	schem = make(map[string]*schema.Table)

	a := schema.NewTable("a")
	a.Version = 0
	a.Columns = append(a.Columns, "eid", "id", "name", "foo")
	a.ColumnIsNumber = append(a.ColumnIsNumber, true, true, false, false)
	a.Indexes = append(a.Indexes, &schema.Index{"PRIMARY", []string{"eid", "id"}})
	a.Indexes = append(a.Indexes, &schema.Index{"a_name", []string{"eid", "name"}})
	a.PKColumns = append(a.PKColumns, 0, 1)
	a.CacheType = 1
	a.CacheSize = 1024
	schem["a"] = a

	b := schema.NewTable("b")
	b.Version = 0
	b.Columns = append(a.Columns, "eid", "id")
	b.ColumnIsNumber = append(a.ColumnIsNumber, true, true)
	b.Indexes = append(a.Indexes, &schema.Index{"PRIMARY", []string{"eid", "id"}})
	b.PKColumns = append(a.PKColumns, 0, 1)
	b.CacheType = 0
	b.CacheSize = 0
	schem["b"] = b

	c := schema.NewTable("c")
	c.Version = 0
	c.Columns = append(a.Columns, "eid", "id")
	c.ColumnIsNumber = append(a.ColumnIsNumber, true, true)
	c.CacheType = 0
	c.CacheSize = 0
	schem["c"] = c
}
Ejemplo n.º 2
0
func loadTableInfo(conn *DBConnection, tableName string) (self *TableInfo) {
	self = &TableInfo{Table: schema.NewTable(tableName)}
	if tableName == "dual" {
		return self
	}
	if !self.fetchColumns(conn) {
		return nil
	}
	if !self.fetchIndexes(conn) {
		return nil
	}
	return self
}