Sql template variable optional clauses are always included for field filters?

hi all! if i have a sql template variable that i put in an optional clause, with double brackets, and then set to a field filter, the optional clause is always included, even if no value is provided. the value is set to 1=1.

for example, this query has invalid SQL in the optional clause:

select * from global_state_globalstate
where True [[and foo {{key}} bar]]

and it fails with a syntax error even if the key variable is unset. if i change it from field filter to e.g. text, it correctly omit the optional clause and runs fine.

is this intentional? i didn’t find anything on https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html that mentioned it.

thanks in advance!