You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
set session my.vars.customer_id ='0192bad7-f177-7578-8b03-700c33509ea1' ;
SELECT*FROM customers WHERE id = current_setting('my.vars.customer_id')::uuid \gx
More Complete Example
set session my.vars.customer_id ='0192bad7-f177-7578-8b03-700c33509ea1' ;
set session my.vars.types ='email,password,phone' ;
set session my.vars.include_revoked = TRUE ;
SELECT"authc"."id"AS"id",
"authc"."priority"AS"priority",
"authc"."type"AS"type",
"authc"."value"AS"value",
"authc"."verified_at"AS"verified_at",
"authc"."created_at"AS"created_at",
"authc"."updated_at"AS"updated_at",
"authc"."revoked_at"AS"revoked_at",
CASE
WHEN "authc"."details" IS NULL THEN NULL
ELSE my_decrypt( "authc"."details" )
END AS"details"FROM"authenticators"AS"authc"WHERE"authc"."customer_id"= current_setting('my.vars.customer_id')::uuid
AND (
"authc"."type"= ANY(string_to_array(current_setting('my.vars.types')::varchar, ','))
OR string_to_array(current_setting('my.vars.types')::varchar, ',') IS NULLOR array_length(string_to_array(current_setting('my.vars.types')::varchar, ','), 1) =0
)
AND (
current_setting('my.vars.include_revoked')::bool = TRUE
OR"revoked_at" IS NULL
)
ORDER BY"authc"."priority"ASC,
"authc"."value"ASC
\gx
The text was updated successfully, but these errors were encountered:
coolaj86
changed the title
doc: How to use Postgres variables in raw SQL query
doc: How to use Postgres variables in test SQL file
Feb 2, 2025
For testing a dynamic query with variables:
Simple Example
More Complete Example
The text was updated successfully, but these errors were encountered: