-
Notifications
You must be signed in to change notification settings - Fork 40
/
value.go
43 lines (39 loc) · 896 Bytes
/
value.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package kql
import (
"fmt"
"github.com/Azure/azure-kusto-go/azkustodata/types"
"github.com/Azure/azure-kusto-go/azkustodata/value"
"github.com/google/uuid"
"github.com/shopspring/decimal"
"time"
)
func QuoteValue(v value.Kusto) string {
val := v.GetValue()
t := v.GetType()
if val == nil {
return fmt.Sprintf("%v(null)", t)
}
switch t {
case types.String:
return QuoteString(v.String(), false)
case types.DateTime:
val = FormatDatetime(*val.(*time.Time))
case types.Timespan:
val = FormatTimespan(*val.(*time.Duration))
case types.Dynamic:
val = string(val.([]byte))
case types.Bool:
val = *val.(*bool)
case types.Int:
val = *val.(*int32)
case types.Long:
val = *val.(*int64)
case types.Real:
val = *val.(*float64)
case types.Decimal:
val = *val.(*decimal.Decimal)
case types.GUID:
val = *val.(*uuid.UUID)
}
return fmt.Sprintf("%v(%v)", t, val)
}