(column, key, dir string)
| 153 | } |
| 154 | |
| 155 | func (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 |
nothing calls this directly
no test coverage detected