Closed jesus-hergueta closed 2 months ago
I make a little debug and found that the query is no returning a single value as response, so maybe the bug is that the table is not rendering a default table when empty
{
"ok": true,
"database": "my_db",
"query_name": null,
"rows": [],
"truncated": false,
"columns": [
"restaurant_name",
"active_date"
],
"query": {
"sql": "select * from my_table",
"params": {}
},
"error": null,
"private": false,
"allow_execute_sql": true,
"query_ms": 375.5116881802678
}
Thanks @jesus-hergueta for submitting this issue! Indeed, currently chart components do not have any fallback in case no rows are returned by the SQL query, the table
chart included.
I'll look into an implementation to handle empty queries by displaying a warning message
if (data.rows && data.rows.length > 0) { Object.keys(data.rows[0]).forEach(col => { // Your existing code }); } else { console.error('No rows returned by the query or data.rows is undefined'); }
I'm receiving this error:
TypeError: Cannot convert undefined or null to object
In this line:
https://github.com/rclement/datasette-dashboards/blob/79af345455f9fc5f995f6c8a472faff25688c089/datasette_dashboards/static/dashboards.js#L141
It just happen the first time I load the dashboard, I have multiples tables and all of them are rendering good.
I'm declaring my tables like this: