How do you make a table use the field ID as the column name versus making one up itself?

It doesn't matter if I'm using SQL, uploaded spreadsheet etc. All my field names are in snake case, so order_number, transaction_date, customer_msd_code etc. Yet when I add a table to my app and select the query as the data source, it adds all columns like Order number, Transaction date, Customer msd code, etc.

Is there a way to stop this as some of my tables have 100+ columns and it's so tedious having to go in and change it all editing each label to be the id instead. It's especially annoying as even with the default it's ugly, like it doesn't use proper case or capitals, so even if I did want it to write it out the way it does, it should be "Customer MSD Code" or "Transaction Date" not all lower case, as I'm still forced to go in and edit each field every single time.

What's even worse is if you export the table, it exports to CSV using the wrong names as well.

Why does it not respect the field names from the query?

Can this be changed or is this by design?

Second question, is there a way to have all fields show on a table by default as string? It's virtually wrong every time it picks a field type. It will be currency yet retool shows it as JSON, or it will be numeric and it shows it as percentage. Standard text/string fields it will also show as JSON. There will be 5 fields all identical in SQL, all float with 2 decimal points yet retool shows them as 3 different field types, 2 will be "tag", 1 will be "percentage", 1 will be "json" and 1 will be text. It's bad enough having to rename all the ID's above, but then you have to go and change 90% of the field types as it picks them as the wrong type every time. I honestly believe it would be more accurate if it was just randomly picking the fields vs whatever logic it uses today.

Hi @psychobunny83, there is a way to do both. Here is how to do it:

First, remove all columns from your "Table" component. Then, go to "Advanced" settings, enable dynamic columns, and set the labels to {{Object.values([i]}}. This will get the column names to be exactly how they are in your db table:

As you can see at the bottom of the screenshot, all column names are set to snake_case. On the same settings, if you select "String" for the "Format" field, all of the values will be set to strings.

Finally, when you export a table with these settings using utils.exportData(), your column names will persist. Here is an screenshot of the .csv file I got:

Happy building! :hammer_and_pick: