Execute condition in WHERE clause only if switch is on

I would like a condition in the WHERE statement of PostgreSQL which says AND assets.project_name=users.user_active_project to be executed only if Switch1 is on.

I was thinking perhaps adding something like {{Switch1.isSwitchedOn ? true : false }} in the WHERE statement of the SQL but I do not know how to insert AND assets.project_name=users.user_active_project in the true condition and then say nothing to happen if false.

You can use a CASE statement with {{Switch1.value == true}}
PostgreSQL CASE.

thanks @ScottR

What I do not know is how to insert the reference to Switch1 in the SQL statement.
I have tried the following but it does not work:

CASE WHEN {{Switch1.isSwitchedOn}} THEN assets.project_name=users.user_active_project END

{{Switch1.value == true}}
https://docs.retool.com/docs/javascript-in-retool#ternaries