Atlas › Test
unquoted_string
Exact test identity: go.temporal.io/server/common/sqlquery/TestConvertSqlValue/unquoted_string
- Package
go.temporal.io/server/common/sqlquery
- Suite / test hierarchy
TestConvertSqlValue/unquoted_string
- Test
unquoted_string
- Introduced at
- query.go ×1 Frontier kind: Joint frontier
- Covered ranges
- 5
- Covered lines
- 6
- Covered files
- 1
Co-introduced tests
1 other test enter at the same concept.
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/common/sqlquery/query.go 6 covered LOC · 5 ranges
Open complete file
49
50
// ParseValue returns a string, int64 or float64 if the parsing succeeds.
51
>
func ParseValue(sqlValue string) (any, error) {
query.go
52
>
if sqlValue == "" {
53
return "", nil
54
}
55
56
>
if sqlValue[0] == '\'' && sqlValue[len(sqlValue)-1] == '\'' {
query.go
57
strValue := strings.Trim(sqlValue, "'")
58
return strValue, nil
60
61
// Unquoted value must be a number. Try int64 first.
62
>
if intValue, err := strconv.ParseInt(sqlValue, 10, 64); err == nil {
query.go
63
return intValue, nil
64
}
65
66
// Then float64.
67
>
if floatValue, err := strconv.ParseFloat(sqlValue, 64); err == nil {
query.go
68
return floatValue, nil
69
}
70
71
>
return nil, serviceerror.NewInvalidArgumentf("invalid expression: unable to parse %s", sqlValue)
query.go
72
}