I have created a SQL PIVOT table to use for my Chart to have multiple datasets.
Some of the column names has spaces e.g. “cash advance”.
I noticed that if the column name has spaces (i.e. cash advance, Wappler is not able to plot the line.
The query has no issue.
I was able to generate an output via Query Builder:
Only when I update my table, and changed the column name to remove the space (e.g. changed it to cash_advance) was Wappler able to plot the lines.
I have also tried to re-create the chart and just use a single dataset instead of multiple datasets using the column name with spaces — still the same issue.
It is working if I use a column name without a space in between (e.g. loan or cash_advance).
Is this a bug or do I need to change something somewhere to make this work?
Hello,
It’s never a great idea to use spaces in your database table names.
The best thing you can do is to use lowercase_underscore_pattern for naming your DB column names.
Hi @Teodor, yes that is correct. All my column names has no spaces. But this is a PIVOT TABLE. The column names are actually fields pivoted into columns.
ie.
Pivoted into:
Also, from my understanding, the results passed over to the page are already in array format. Are there any issues if the name has spaces?
Nope. There are no errors actually. Everything seems to be working fine. You can also see that the query is able to return the results. Maybe there is an issue reading the array values when there spaces in the name?
Well since it has already been 2 weeks and I need to make this work, I just went ahead and added a new column for an alias name in my table. On my page, I used the Underscore Data Format Transform to automatically add an “_” (underscore) to the original name and save it as the alias name. Then I have modified the PIVOT query to use this.