コード例 #1
0
func Example() {
	t1 := sb.NewTable(
		"parent_prefix",
		sb.IntColumn("ns_id", false),
		sb.IntColumn("hash", false),
		sb.StrColumn(
			"prefix",
			sb.UTF8,
			sb.UTF8CaseInsensitive,
			false))

	t2 := sb.NewTable(
		"sfj",
		sb.IntColumn("ns_id", false),
		sb.IntColumn("sjid", false),
		sb.StrColumn(
			"filename",
			sb.UTF8,
			sb.UTF8CaseInsensitive,
			false))

	ns_id1 := t1.C("ns_id")
	prefix := t1.C("prefix")
	ns_id2 := t2.C("ns_id")
	sjid := t2.C("sjid")
	filename := t2.C("filename")

	in := []int32{1, 2, 3}
	join := t2.LeftJoinOn(t1, sb.Eq(ns_id1, ns_id2))
	q := join.Select(ns_id2, sjid, prefix, filename).Where(
		sb.And(sb.EqL(ns_id2, 123), sb.In(sjid, in)))
	fmt.Println(q.String("shard1"))
}
コード例 #2
0
ファイル: reader.go プロジェクト: samuelyao314/mygo
func (r *logReader) newInsertStat(logid uint, tblName string) sqlbuilder.InsertStatement {
	cfg := r.logConfByID(logid)

	columns := make([]sqlbuilder.NonAliasColumn, len(cfg.Field_list))
	for i := 0; i < len(cfg.Field_list); i++ {
		field := &cfg.Field_list[i]
		if field.TypeInt == prod.FIELD_TYPE_INT {
			columns[i] = sqlbuilder.IntColumn(field.Column, true)
		} else if field.TypeInt == prod.FIELD_TYPE_UINT {
			columns[i] = sqlbuilder.IntColumn(field.Column, true)
		} else {
			columns[i] = sqlbuilder.BytesColumn(field.Column, true)
		}
	}
	table := sqlbuilder.NewTable(tblName, columns...)
	return table.Insert(columns...)
}