Variables not working when used in strings - v0.46

As discussed on this topic on 'Get Help', there appears to be a bug with the behavior of variables used in strings after updating to v0.46

I used to have a variable {{default_days}} that was used in the query to define whether table column default_d1 or default_d15 should be used

I used it as follows, and it worked just fine prior to v0.46

from default

Now, after updating to v0.46, I get the error

ERROR: column "default_d$2" does not exist

It happens whether the variable type is set to 'Text' or 'Number'

Funny thing is, when I select the variable by itself, it returns the value it is set to.
select {{default_days}} returns '1' or '15' depending on what is inputed to the filter. But when using it on a string, it appears to be evaluated as '$2'

Could this have been caused by changes made to the variables in v0.46? For instance, there were changes to make it possible to create a custom list for a dropdown text variable.

  • Your browser and its version: Chrome 111.0.5563.146
  • Your operating system: Windows 11
  • The type of database(s) you've connected to Metabase: Postgres
  • The version of Metabase you're running: 0.46
  • Repeatable steps to reproduce the issue: create a SQL query that uses a variable in a table column name

@Luiggi would you mind helping with this?

seems we broke this in 46, but it was never something we supported officially

Oh, I see. It was actually a great "unexpected" feature, since we could build queries to provide different field calculations according to what was passed to the filter.

Would be great to have it working again - and included to the official features :slight_smile: