// SQLNullStringKeyOmitEmpty adds a string to be encoded or skips it if it is zero value.
// Must be used inside an object as it will encode a key
772732
func (enc *Encoder) SQLNullStringKeyOmitEmpty(key string, v *sql.NullString) {
	if v != nil && v.Valid && v.String != "" {
		enc.StringKeyOmitEmpty(key, v.String)
	}
}
550722
func String(s string) NullString {
	return NullString{
		sql.NullString{
			String: s,
			Valid:  true,
		},
	}
}
1305984
func (enc *Encoder) EncodeSQLNullInt64(v *sql.NullInt64) error {
	if enc.isPooled == 1 {
		panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
	}
	_, _ = enc.encodeInt64(v.Int64)
	_, err := enc.Write()
	if err != nil {
		enc.err = err
		return err
	}
	return nil
}
552573
func (enc *Encoder) SQLNullBoolOmitEmpty(v *sql.NullBool) {
	if v != nil && v.Valid && v.Bool != false {
		enc.Bool(v.Bool)
	}
}
483307
func (dec *Decoder) SQLNullString(v *sql.NullString) error {
	var b *string
	if err := dec.StringNull(&b); err != nil {
		return err
	}
	if b == nil {
		v.Valid = false
	} else {
		v.String = *b
		v.Valid = true
	}
	return nil
}
221164
func queryAsString(sql string, bindVariables map[string]*querypb.BindVariable) string {
	buf := &bytes.Buffer{}
	fmt.Fprintf(buf, "Sql: %q", sql)
	fmt.Fprintf(buf, ", BindVars: {")
	var keys []string
	for key := range bindVariables {
		keys = append(keys, key)
	}
	sort.Strings(keys)
	var valString string
	for _, key := range keys {
		valString = fmt.Sprintf("%v", bindVariables[key])
		fmt.Fprintf(buf, "%s: %q", key, valString)
	}
	fmt.Fprintf(buf, "}")
	return buf.String()
}
1037472
func (t SQLNullTime) MarshalJSON() ([]byte, error) {
	if !t.Valid {
		return jsonex.Marshal(nil)
	}
	return jsonex.Marshal(t.Time)
}
638237
func (enc *Encoder) AddBoolKeyNullEmpty(key string, v bool) {
	enc.BoolKeyNullEmpty(key, v)
}
452404
func (enc *Encoder) AddStringKeyOmitEmpty(key, v string) {
	enc.StringKeyOmitEmpty(key, v)
}
52322
func (enc *Encoder) Int32KeyNullEmpty(key string, v int32) {
	enc.Int64KeyNullEmpty(key, int64(v))
}
978625
func (enc *Encoder) ObjectOmitEmpty(v MarshalerJSONObject) {
	if v.IsNil() {
		return
	}
	enc.grow(2)
	r := enc.getPreviousRune()
	if r != '[' {
		enc.writeByte(',')
	}
	enc.writeByte('{')

	var origHasKeys = enc.hasKeys
	var origKeys = enc.keys
	enc.hasKeys = false
	enc.keys = nil

	v.MarshalJSONObject(enc)

	enc.hasKeys = origHasKeys
	enc.keys = origKeys

	enc.writeByte('}')
}
142927
func (enc *Encoder) SQLNullStringNullEmpty(v *sql.NullString) {
	if v != nil && v.Valid {
		enc.StringNullEmpty(v.String)
	}
}
456454
func (enc *Encoder) EncodeSQLNullString(v *sql.NullString) error {
	if enc.isPooled == 1 {
		panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
	}
	_, _ = enc.encodeString(v.String)
	_, err := enc.Write()
	if err != nil {
		enc.err = err
		return err
	}
	return nil
}
952680
func (dec *Decoder) SQLNullFloat64(v *sql.NullFloat64) error {
	var b *float64
	if err := dec.Float64Null(&b); err != nil {
		return err
	}
	if b == nil {
		v.Valid = false
	} else {
		v.Float64 = *b
		v.Valid = true
	}
	return nil
}
389903
func (enc *Encoder) SQLNullBoolNullEmpty(v *sql.NullBool) {
	if v != nil && v.Valid {
		enc.BoolNullEmpty(v.Bool)
	}
}
783517
func EncodeToString(dst interface{}) (string, error) {
	v := reflect.ValueOf(dst)
	n, err := encodeToNode(v, false)
	if err != nil {
		return "", err
	}
	vs := n.values(defaultDelimiter, defaultEscape)
	return vs.Encode(), nil
}
1208810
func SQL(dst io.Writer, v interface{}, options ...Option) error {
	ctx := newFmtCtx(dst)
	for _, o := range options {
		switch o.Name() {
		case optkeyIndent:
			ctx.indent = o.Value().(string)
		}
	}

	return format(ctx, v)
}