Postgres/MySQL/MSSQL: Fix name of time field should be named Time for time series queries (#36720)

Name of time field changed in v8 for time series queries from Time to the name of the selected 
time column, i.e. time or time_sec. These changes should make sure that the name of time field 
is always returned as Time for time series queries.

Fixes #36059

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Marcus Efraimsson
2021-07-14 11:29:51 +02:00
committed by GitHub
co-authored by Ryan McKinley
parent 92801d5fa1
commit 10c892fa5b
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -283,6 +283,10 @@ func (e *dataPlugin) executeQuery(query plugins.DataSubQuery, wg *sync.WaitGroup
errAppendDebug("db has no time column", errors.New("no time column found"), interpolatedQuery)
return
}
// Make sure to name the time field 'Time' to be backward compatible with Grafana pre-v8.
frame.Fields[qm.timeIndex].Name = data.TimeSeriesTimeFieldName
for i := range qm.columnNames {
if i == qm.timeIndex || i == qm.metricIndex {
continue