Handle scalar TG extracted payloads

This commit is contained in:
Grendgi
2026-06-05 16:31:20 +03:00
parent 76b6230c7a
commit fd6fc6b931

View File

@@ -300,7 +300,12 @@ func (c *classifier) resolvePrompt(ctx context.Context, vertical, departmentID,
func (c *classifier) saveVerdict(ctx context.Context, id int64, key string, verdict json.RawMessage) error {
_, err := c.db.Exec(ctx, `
UPDATE messages
SET extracted = jsonb_set(COALESCE(extracted, '{}'::jsonb), ARRAY[$2], $3::jsonb, true)
SET extracted = jsonb_set(
CASE WHEN jsonb_typeof(extracted) = 'object' THEN extracted ELSE '{}'::jsonb END,
ARRAY[$2],
$3::jsonb,
true
)
WHERE id = $1
`, id, key, string(verdict))
return err