Variable order getting randomized

Hello, I’m currently creating a rather large scale native sql query query with a lot variable filters.
To illustrate:

SELECT table1.col1 as aaa,
table1.col2 as bbb,
view1.col1 as ccc
FROM table1
INNER JOIN table2 ON table1.table2_id = table2.id 
INNER JOIN table3 ON table1.table3_id = table3.id 
INNER JOIN table4 ON table1.table4_id = table4.id 
INNER JOIN view1 ON table1.id = view1.id 
LEFT JOIN table5 ON table1.table5_id = table5.id 
LEFT JOIN table6 ON table1.table6_id = table6.id
WHERE 1=1
[[AND CAST(view1.date1 AS date) >= {{var1}} ]]
[[AND CAST(view1.date2 AS date) <= {{var2}} ]]
[[AND {{var3}} ]]
[[AND {{var4}} ]]
[[AND {{var5}} ]]
[[AND {{var6}} ]]
[[AND {{var7}} ]]
[[AND table1.col4 <= {{var8}} ]]
[[AND table3.col6 >= {{var9}} ]]
[[AND {{var10}} ]]
;

With a couple variables (sometimes up to 9) variables stay in order when I save the question but sometimes they are reordered (pretty randomly to me) on saving - in UI instead of var1, var2, var3… I have var5,var8, var2 or sth like this. I’ve tried this with multiple different variablesand it seems to happen 100% times when I have 9 or more variables, possibly in some other conditions aswell.

I am using Postgres database with latest version of metabase.

1 Like

Did you find a solution?

I think you’re having this issue (first link), which randomizes the parameters, where more having more than 8. And there’s a bug in the re-ordering too (second link).
Go and vote, by clicking the :+1: on the first post of each issue:
https://github.com/metabase/metabase/issues/5136
https://github.com/metabase/metabase/issues/9357