PrependToMaybeNullArray prepends an element in the front of an arrray. If the argument is NULL, an array of one element is created.
(typ *types.T, left Datum, right Datum)
| 228 | // PrependToMaybeNullArray prepends an element in the front of an arrray. |
| 229 | // If the argument is NULL, an array of one element is created. |
| 230 | func PrependToMaybeNullArray(typ *types.T, left Datum, right Datum) (Datum, error) { |
| 231 | result := NewDArray(typ) |
| 232 | if err := result.Append(left); err != nil { |
| 233 | return nil, err |
| 234 | } |
| 235 | if right != DNull { |
| 236 | for _, e := range MustBeDArray(right).Array { |
| 237 | if err := result.Append(e); err != nil { |
| 238 | return nil, err |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | return result, nil |
| 243 | } |
| 244 | |
| 245 | // TODO(justin): these might be improved by making arrays into an interface and |
| 246 | // then introducing a ConcatenatedArray implementation which just references two |
no test coverage detected
searching dependent graphs…