MCPcopy
hub / github.com/ent/ent / value

Method value

dialect/sql/sqljson/sqljson.go:513–530  ·  view source on GitHub ↗

value writes the path for getting the JSON value.

(b *sql.Builder)

Source from the content-addressed store, hash-verified

511
512// value writes the path for getting the JSON value.
513func (p *PathOptions) value(b *sql.Builder) {
514 switch {
515 case len(p.Path) == 0:
516 b.Ident(p.Ident)
517 case b.Dialect() == dialect.Postgres:
518 if p.Cast != "" {
519 b.WriteByte('(')
520 defer b.WriteString(")::" + p.Cast)
521 }
522 p.pgTextPath(b)
523 default:
524 if p.Unquote && b.Dialect() == dialect.MySQL {
525 b.WriteString("JSON_UNQUOTE(")
526 defer b.WriteByte(')')
527 }
528 p.mysqlFunc("JSON_EXTRACT", b)
529 }
530}
531
532// value writes the path for getting the length of a JSON value.
533func (p *PathOptions) length(b *sql.Builder) {

Callers

nothing calls this directly

Calls 6

pgTextPathMethod · 0.95
mysqlFuncMethod · 0.95
IdentMethod · 0.80
WriteByteMethod · 0.80
WriteStringMethod · 0.80
DialectMethod · 0.65

Tested by

no test coverage detected