bmaquet commented on PR #32770:
URL: https://github.com/apache/superset/pull/32770#issuecomment-2742683899

   I've updated the logic based on @mistercrunch 's recommandations.
   
   The function now returns an array of roles, instead of a JSON-stringified 
array.
   This allows users to leverage arrays to run statements like 
   ```
   SELECT
   '{{ 'yes' if 'Alpha' in current_user_roles() else 'no'  }}' as 
is_alpha_in_roles
   ```
   but also to get the list of roles in a properly formatted SQL string by 
using `|tojson`
   ```
   SELECT '{{ current_user_roles()|tojson }}' as roles
   ```
   
   The array of roles is added to the cache key by turning it into a string 
using `json.dumps()`. This allows the query to be cached and returned from the 
cache.
   
   <img width="1506" alt="Screenshot 2025-03-21 at 09 26 35" 
src="https://github.com/user-attachments/assets/f8e26e46-d39b-42f8-beb8-2a1d6bbd2f43";
 />
   <img width="1508" alt="Screenshot 2025-03-21 at 09 26 44" 
src="https://github.com/user-attachments/assets/9ef5ca53-f453-4450-b90b-52788e46383e";
 />
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to