influxDB last() quoting possible?

Everything has been working great for years now, and is still working well on all the devices, but after a while I noticed something odd when my IoTaWatts would do their 6-week routine restart. It would start back at the “upload history from” date. I found some other similar issues, but nothing exactly like this on the forum, so I figured I would ask here and see if there was an easy resolution. (Sorry if I missed this exact thing somewhere.)
I didn’t notice at first since it would upload over the influxDB data quickly and would come back to present pretty fast, but as the time went on the delay would get longer since it had more to reupload, I figured out it must not be able to detect the last date in the database reliably, so it would start from the beginning date again, and setting it to something recent would update quickly again.

For diagnostics, I wiresharked the query to see what it was requesting. As expected, it selects the LAST() for the fields in the measurement using that tag. It looked OK, but got an error back, and when I used the console to double check with the same query it complained with the same error, “expected field argument in last()”.
After looking up the influx query language, I realized that LAST() requires the identifier to be double-quoted if it contains anything other than alphanumeric or the underscore character (per the rules at Influx Query Language (InfluxQL) reference | InfluxDB OSS v1 Documentation ), and unfortunately I used a dash in the field key (specifically I used $name-$units). I tested it with double quotes in the influx console and then it worked OK. So I unintentionally sabotaged myself with a dash when I could have used an underscore. :flushed: :person_facepalming:
For clarity:

> SELECT LAST(HeatPumpGeo-Watts) FROM IotaHomeData  WHERE dev='HomeIota'
ERR: expected field argument in last()
> SELECT LAST("HeatPumpGeo-Watts") FROM IotaHomeData  WHERE dev='HomeIota'
name: IotaHomeData
time                last
----                ----
1721272270000000000 1505.15

I was wondering if there was any way to enable quoting on the LAST() query field request, or something I could enter manually in the config to enable it so it would quote the identifier used in LAST()? I would like to avoid having to redo the database and grafana configs to remove all dashes from field keys after changing the devices, so I could get the resume to work correctly? If not then I’ll take the long way around, but I figured I would check all bases first before going that route, since there might be a simple fix?

Thanks!

JB

That’s what I like. A problem report with a solution. Nice work. I’ll add those quotes in the next release. Thanks.

Oh! Excellent! Thank you too! That sounds great to me! :grin: :grin:

JB