MCPcopy
hub / github.com/cube2222/octosql / BuildIntegral

Function BuildIntegral

parser/sqlparser/dependency/sqltypes/value.go:174–184  ·  view source on GitHub ↗

BuildIntegral builds an integral type from a string representaion. The type will be Int64 or Uint64. Int64 will be preferred where possible.

(val string)

Source from the content-addressed store, hash-verified

172// BuildIntegral builds an integral type from a string representaion.
173// The type will be Int64 or Uint64. Int64 will be preferred where possible.
174func BuildIntegral(val string) (n Value, err error) {
175 signed, err := strconv.ParseInt(val, 0, 64)
176 if err == nil {
177 return MakeTrusted(Int64, strconv.AppendInt(nil, signed, 10)), nil
178 }
179 unsigned, err := strconv.ParseUint(val, 0, 64)
180 if err != nil {
181 return Value{}, err
182 }
183 return MakeTrusted(Uint64, strconv.AppendUint(nil, unsigned, 10)), nil
184}
185
186// Type returns the type of Value.
187func (v Value) Type() querypb.Type {

Callers 1

TestBuildIntegralFunction · 0.85

Calls 1

MakeTrustedFunction · 0.85

Tested by 1

TestBuildIntegralFunction · 0.68