func expectComparisonResult(ctx *cqlc.Context, s *gocql.Session, callback func([]ClusterByStringAndInt) bool, comparisons ...cqlc.Condition) bool { iter, err := ctx.Select(). From(CLUSTER_BY_STRING_AND_INT). Where(comparisons...). Fetch(s) if err != nil { log.Fatalf("Could not run query: %v", err) os.Exit(1) } clustered, err := BindClusterByStringAndInt(iter) if err != nil { log.Fatalf("Could not bind data: %v", err) os.Exit(1) } err = iter.Close() if err != nil { log.Fatalf("Could not bind data: %v", err) os.Exit(1) } return callback(clustered) }
func fetchOne(ctx *cqlc.Context, s *gocql.Session, w WhenRowKey, t gocql.UUID, binding cqlc.ColumnBinding) (bool, error) { return ctx. Select(). From(w). Where(w.WhenColumn().Eq(t)). Bind(binding). FetchOne(s) }
func fetchFirstBasic(ctx *cqlc.Context, s *gocql.Session, key string) *Basic { iter, err := ctx.Select().From(REALLY_BASIC).Where(REALLY_BASIC.ID.Eq("x")).Fetch(s) basics, err := BindBasic(iter) if err != nil { log.Fatalf("Could not bind data: %v", err) os.Exit(1) } err = iter.Close() if err != nil { log.Fatalf("Could not bind data: %v", err) os.Exit(1) } if len(basics) > 0 { return &basics[0] } else { return nil } }
func fetchFirstReallyBasic(ctx *cqlc.Context, s *gocql.Session, key string) ReallyBasic { iter, err := ctx.Select().From(REALLY_BASIC).Where(REALLY_BASIC.ID.Eq(key)).Fetch(s) basics, err := BindReallyBasic(iter) if err != nil { log.Fatalf("Could not bind data: %v", err) os.Exit(1) } err = iter.Close() if err != nil { log.Fatalf("Could not bind data: %v", err) os.Exit(1) } if len(basics) != 1 { log.Fatalf("Could not fetch data for key: %s", key) os.Exit(1) } return basics[0] }