fix: use dollar-quoting for PL/pgSQL trigger function

The previous single-quote syntax with escaped quotes was split by
split_sql_statements on semicolons inside the function body.
Use $$ quoting to avoid quote escaping issues.
This commit is contained in:
ZhenYi 2026-04-15 11:31:40 +08:00
parent b6697258ab
commit 8e7f3b211e

View File

@ -29,12 +29,12 @@ CREATE INDEX IF NOT EXISTS idx_room_message_content_tsv ON room_message USING GI
-- Trigger to auto-update content_tsv on insert/update
CREATE OR REPLACE FUNCTION room_message_tsv_trigger() RETURNS TRIGGER AS
'
BEGIN
NEW.content_tsv := to_tsvector(''simple'', COALESCE(NEW.content, ''''));
RETURN NEW;
END;
' LANGUAGE plpgsql;
$$
BEGIN
NEW.content_tsv := to_tsvector('simple', COALESCE(NEW.content, ''));
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER room_message_tsv_update
BEFORE INSERT OR UPDATE