NewArray returns a new *Array.
(coercedType sql.Type)
| 39 | |
| 40 | // NewArray returns a new *Array. |
| 41 | func 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. |
| 61 | func (array *Array) Children() []sql.Expression { |
nothing calls this directly
no test coverage detected