value writes the path for getting the length of a JSON value.
(b *sql.Builder)
| 531 | |
| 532 | // value writes the path for getting the length of a JSON value. |
| 533 | func (p *PathOptions) length(b *sql.Builder) { |
| 534 | switch { |
| 535 | case b.Dialect() == dialect.Postgres: |
| 536 | b.WriteString("JSONB_ARRAY_LENGTH(") |
| 537 | p.pgTextPath(b) |
| 538 | b.WriteByte(')') |
| 539 | case b.Dialect() == dialect.MySQL: |
| 540 | p.mysqlFunc("JSON_LENGTH", b) |
| 541 | default: |
| 542 | p.mysqlFunc("JSON_ARRAY_LENGTH", b) |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | // mysqlFunc writes the JSON path in MySQL format for the |
| 547 | // given function. `JSON_EXTRACT("a", '$.b.c')`. |
no test coverage detected