MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / JSONFieldOrder

Method JSONFieldOrder

internal/store/dialect_fieldvalue.go:155–162  ·  view source on GitHub ↗
(column, key, dir string)

Source from the content-addressed store, hash-verified

153}
154
155func (d *postgresDialect) JSONFieldOrder(column, key, dir string) string {
156 t := fmt.Sprintf("jsonb_typeof(%s->'%s')", column, key)
157 rank := fmt.Sprintf("(CASE COALESCE(%s, 'null')"+
158 " WHEN 'number' THEN 0 WHEN 'string' THEN 1 WHEN 'boolean' THEN 2"+
159 " WHEN 'null' THEN 4 ELSE 3 END)", t)
160 num := fmt.Sprintf("(CASE WHEN %s = 'number' THEN (%s->'%s')::numeric END)", t, column, key)
161 return fmt.Sprintf("%s ASC, %s %s, %s %s", rank, num, dir, d.JSONFieldText(column, key), dir)
162}
163
164// NumericClaimForms is the form under which JSONFieldEquals could find two
165// numeric values equal, on either dialect, for arg when numericArg accepts

Callers

nothing calls this directly

Calls 1

JSONFieldTextMethod · 0.95

Tested by

no test coverage detected