MCPcopy Index your code
hub / github.com/ent/ent / normalizePG

Function normalizePG

dialect/sql/sqljson/sqljson.go:657–672  ·  view source on GitHub ↗

normalizePG adds cast option to the JSON path is the argument type is not string, in order to avoid "missing type casts" error in Postgres.

(b *sql.Builder, arg any, opts []Option)

Source from the content-addressed store, hash-verified

655// normalizePG adds cast option to the JSON path is the argument type is
656// not string, in order to avoid "missing type casts" error in Postgres.
657func normalizePG(b *sql.Builder, arg any, opts []Option) []Option {
658 if b.Dialect() != dialect.Postgres {
659 return opts
660 }
661 base := []Option{Unquote(true)}
662 switch arg.(type) {
663 case string:
664 case bool:
665 base = append(base, Cast("bool"))
666 case float32, float64:
667 base = append(base, Cast("float"))
668 case int8, int16, int32, int64, int, uint8, uint16, uint32, uint64:
669 base = append(base, Cast("int"))
670 }
671 return append(base, opts...)
672}
673
674func isIdentifier(name string) bool {
675 if name == "" {

Callers 8

ValueEQFunction · 0.85
ValueNEQFunction · 0.85
ValueGTFunction · 0.85
ValueGTEFunction · 0.85
ValueLTFunction · 0.85
ValueLTEFunction · 0.85
ValueContainsFunction · 0.85
valueInOpFunction · 0.85

Calls 3

UnquoteFunction · 0.85
CastFunction · 0.85
DialectMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…