mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 07:42:31 +08:00
Postgres/MySQL/MSSQL: Fix region annotations not displayed correctly (#38936)
Fix region annotations not displayed correctly when returning timeend column as epoch timestamp and by that making sure that the returned data frame field named timeend is treated as time type. Fixes #38533
This commit is contained in:

committed by
GitHub

parent
9aa03acfa6
commit
fbdaf56a84
@ -1199,6 +1199,32 @@ func TestPostgres(t *testing.T) {
|
||||
// Should be in time.Time
|
||||
assert.Nil(t, frames[0].Fields[0].At(0))
|
||||
})
|
||||
|
||||
t.Run("When doing an annotation query with a time and timeend column should return two fields of type time", func(t *testing.T) {
|
||||
query := &backend.QueryDataRequest{
|
||||
Queries: []backend.DataQuery{
|
||||
{
|
||||
JSON: []byte(`{
|
||||
"rawSql": "SELECT 1631053772276 as time, 1631054012276 as timeend, '' as text, '' as tags",
|
||||
"format": "table"
|
||||
}`),
|
||||
RefID: "A",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := exe.QueryData(context.Background(), query)
|
||||
require.NoError(t, err)
|
||||
queryResult := resp.Responses["A"]
|
||||
require.NoError(t, queryResult.Error)
|
||||
|
||||
frames := queryResult.Frames
|
||||
require.Equal(t, 1, len(frames))
|
||||
require.Equal(t, 4, len(frames[0].Fields))
|
||||
|
||||
require.Equal(t, data.FieldTypeNullableTime, frames[0].Fields[0].Type())
|
||||
require.Equal(t, data.FieldTypeNullableTime, frames[0].Fields[1].Type())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user