func RunRawSQL2(TM ITransactionManager, t *testing.T) { ResetDB(TM) // get the database connection dba := dbx.NewSimpleDBA(TM.Store().GetConnection()) var result []string err := dba.QueryClosure(RAW_SQL, func(rows *sql.Rows) error { var name string if err := rows.Scan(&name); err != nil { return err } result = append(result, name) return nil }, "%book") if err != nil { t.Fatalf("Failed TestRawSQL2: %s", err) } for k, v := range result { logger.Debugf("books[%v] = %s", k, v) if v == "" { t.Fatal("Expected a valid Name, but got empty") } } }
func (this *DmlBase) Super(DB IDb, table *Table) { this.db = DB this.table = table this.alias(PREFIX + "0") if table != nil { this.discriminatorCriterias = table.GetCriterias() } this.parameters = make(map[string]interface{}) this.dba = dbx.NewSimpleDBA(DB.GetConnection()) }
func RunRawSQL1(TM ITransactionManager, t *testing.T) { ResetDB(TM) // get the database connection dba := dbx.NewSimpleDBA(TM.Store().GetConnection()) var result []string _, err := dba.QueryInto(RAW_SQL, func(name string) { // we calso use pointers: func(name *string) result = append(result, name) }, "%book") if err != nil { t.Fatalf("Failed TestRawSQL1: %s", err) } for k, v := range result { logger.Debugf("books[%v] = %s", k, v) if v == "" { t.Fatal("Expected a valid Name, but got empty") } } }