I'm using Retool as a frontend to a new database (Retool's Postgres). This means that the database doesn't have data in many of the tables.
The queries run fine, and I can see the column names in the "Output" when clicking "Save and Run."
Unfortunately, when adding a new table to my UI and choosing the SQL query as a data source, Retool shows a red message, "The selected data source could not be converted to an array." Of course, I also can't add the table columns.
If you are using Retool Database, you might need to add in a single row of dummy data so that the SQL query to this table is able to grab the data and format it to an array that the table can read.
Can you share screenshots of the current query you are using with its results?
When you said you can't add table columns, does the plus button(right of lettuce) not pull up this modal for a new column?
For the table, it will show that error message when there is no data in the table but will display the column names in the query result. This will go away when you have some rows of data in your table.
Jack, what doesn't make sense is, if the query recognizes the columns in the preview, the table component editor should also recognize them.
When I said I can't add table columns, I'm referring to I can't add columns to the table component. (I'm managing the database through DataGrip remotely.)
I agree, given that users can see a query result return the columns, logically it should make sense that the table component can read these and display the column headers.
It seems to be a quirk of the code base, that although the column names are keys that because they have either no value or a falsy value paired with them, that the table component is throwing that error and not able to parse it out
I can make a feature request to add in empty table handling!
In the meantime, there are two options you can use to build a table from scratch.
First would be to set the data source to empty, and then use the + symbol (bottom right of screen shot) in the component inspector to generate columns which you can rename as needed.
The second option would be to create an array of objects that would be the table's data source.
You can do this directly inside the table's inspector by clicking the fx button to allow the field to take javascript and then the expander to make the box bigger and easier to work with.