Apologies in advance for a the long post.
My data is stored in a mySQL database with one of the fields being a date field (TIMESTAMP). My flow queries the database and returns the selected values that look like this:
The output then goes through a change node to split up the individual data fields into separate arrays using the JSONATA $spread() function.
This works perfectly on all data EXCEPT the date field (payload.day)
If I copy the data returned from the SQL query (copy the payload without changing the date field) and send it via the inject node, it works correctly.
Inject Node:
Array data:
After $spread() function:
If I use the DATE_FORMAT function (convert to string) in my query it works correctly (but then I cannot use the date/time in a time series chart).
Query:
select round((load_home_imp_per - load_home_exp_per)/1000,2) as 'totalHomeuse', round((site_grid_imp_per)/1000,2) as 'gridToHome', (round((solar_exp_per - solar_imp_per)/1000,2)-round((site_grid_exp_per)/1000,2)-round(battery_pwl_imp_per/1000,2)) as 'solarToHome', round(battery_pwl_exp_per/1000,2) as 'batteryToHome', round((solar_exp_per - solar_imp_per)/1000,2) as 'totalSolar', round((site_grid_exp_per)/1000,2) as 'solarToGrid', round(battery_pwl_imp_per/1000,2) as 'solarToBattery', date_format(created,'%Y-%m-%d')as 'day' from powerwall_cumm where date (created) >= '2022-01-17' and date (created) <= '2022-01-25' :
Array data:
After $spread() function:
I would be happy to post sample data and/or flow, but this ONLY happens when the data is returned via a query and is in TIMESTAMP format, so it is somewhat specific. In order to replicate this, you need to have a mySQL database with a TIMESTAMP column and return multiple columns in your query (including the TIMESTAMP column).
Node-RED v 1.3.5
mySQL node v 1.0.0
Node.js v 14.15.5
Thanks for your help.