コード例 #1
0
ファイル: que.go プロジェクト: maheshbale/que-go
func (b bytea) Encode(w *pgx.WriteBuf, oid pgx.Oid) error {
	if len(b) == 0 {
		w.WriteInt32(-1)
		return nil
	}
	w.WriteInt32(int32(len(b)))
	w.WriteBytes(b)
	return nil
}
コード例 #2
0
func (p NullPoint) Encode(w *pgx.WriteBuf, oid pgx.Oid) error {
	if !p.Valid {
		w.WriteInt32(-1)
		return nil
	}

	s := fmt.Sprintf("point(%v,%v)", p.X, p.Y)
	w.WriteInt32(int32(len(s)))
	w.WriteBytes([]byte(s))

	return nil
}
コード例 #3
0
ファイル: pgxdata_attribute.go プロジェクト: jackc/tpr
func (attr Bytes) Encode(w *pgx.WriteBuf, oid pgx.Oid) error {
	if oid != pgx.ByteaOid {
		return pgx.SerializationError(fmt.Sprintf("Bytes.Encode cannot encode into OID %d", oid))
	}

	if attr.Status != Present {
		w.WriteInt32(-1)
		return nil
	}

	w.WriteBytes(attr.Value)
	return nil
}
コード例 #4
0
ファイル: query_test.go プロジェクト: jonasi/pgx
func (n *coreEncoder) Encode(w *pgx.WriteBuf, oid pgx.Oid) error {
	w.WriteInt32(int32(2))
	w.WriteBytes([]byte("42"))
	return nil
}