File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -66,33 +66,31 @@ BEGIN
6666END $$;
6767
6868-- Helper functions for encryption/decryption (following secrets pattern)
69- -- Modified to return composite types so they can be tracked by Hasura
69+ -- Modified to return SETOF composite types so they return tables that Hasura can track
7070CREATE OR REPLACE FUNCTION encrypt_api_key (
7171 p_value TEXT ,
7272 p_key TEXT
73- ) RETURNS encrypted_api_key_result AS $$
73+ ) RETURNS SETOF encrypted_api_key_result AS $$
7474BEGIN
75- RETURN ROW(
75+ RETURN QUERY SELECT
7676 pgp_sym_encrypt(
7777 p_value,
7878 p_key,
7979 ' cipher-algo=aes256'
80- )
81- )::encrypted_api_key_result;
80+ ) AS encrypted_value;
8281END;
8382$$ LANGUAGE plpgsql SECURITY DEFINER;
8483
8584CREATE OR REPLACE FUNCTION decrypt_api_key (
8685 p_encrypted_value BYTEA ,
8786 p_key TEXT
88- ) RETURNS decrypted_api_key_result AS $$
87+ ) RETURNS SETOF decrypted_api_key_result AS $$
8988BEGIN
90- RETURN ROW(
89+ RETURN QUERY SELECT
9190 pgp_sym_decrypt(
9291 p_encrypted_value,
9392 p_key
94- )
95- )::decrypted_api_key_result;
93+ ) AS decrypted_value;
9694END;
9795$$ LANGUAGE plpgsql SECURITY DEFINER;
9896
You can’t perform that action at this time.
0 commit comments