Fixing DB showing up in A-Z order?

I am trying to figure out where the code is that is causing the DB columns to mostly be imported in A-Z order (except for a few columns at times…)

@yskolnick

Seems like it’s handled by {:order-by [[:position :asc] [:name :asc]]} in ./src/metabase/models/table.clj

But if you remove/comment those order-by’s, then you just end up with however the columns were added to metabase_field (in the metadata database).

This is not simple to fix - my guess is that you need to get the position from the real database table, and then store that in metabase_field.position. That would also allow you to make a frontend that modifies the position.
And then it needs to take into account how sync would work (if you move the columns around in the database or add new columns in between others) - and how to migrate current setups.

Metabase tries to have as few settings as possible and do most things automatically, so I’m not sure if a setting is needed with “A-Z” and “Follow DB structure” options.

And all of this needs to made, so it works for all databases/drivers.