MCPcopy Create free account
hub / github.com/dolthub/doltgresql / NewArray

Function NewArray

server/expression/array.go:41–58  ·  view source on GitHub ↗

NewArray returns a new *Array.

(coercedType sql.Type)

Source from the content-addressed store, hash-verified

39
40// NewArray returns a new *Array.
41func NewArray(coercedType sql.Type) (*Array, error) {
42 var arrayCoercedType *pgtypes.DoltgresType
43 if dt, ok := coercedType.(*pgtypes.DoltgresType); ok {
44 if dt.IsEmptyType() {
45 // DoltgresType pointer can be nil
46 } else if dt.IsArrayType() {
47 arrayCoercedType = dt
48 } else if !dt.IsEmptyType() {
49 return nil, errors.Errorf("cannot cast array to %s", coercedType.String())
50 }
51 } else if coercedType != nil {
52 return nil, errors.Errorf("cannot cast array to %s", coercedType.String())
53 }
54 return &Array{
55 children: nil,
56 coercedType: arrayCoercedType,
57 }, nil
58}
59
60// Children implements the sql.Expression interface.
61func (array *Array) Children() []sql.Expression {

Callers

nothing calls this directly

Calls 4

IsEmptyTypeMethod · 0.80
IsArrayTypeMethod · 0.80
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected