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)
| 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. |
| 657 | func 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 | |
| 674 | func isIdentifier(name string) bool { |
| 675 | if name == "" { |
no test coverage detected
searching dependent graphs…