MakeArray constructs a new instance of an ArrayFamily type with the given element type (which may itself be an ArrayFamily type).
(typ *T)
| 1228 | // MakeArray constructs a new instance of an ArrayFamily type with the given |
| 1229 | // element type (which may itself be an ArrayFamily type). |
| 1230 | func MakeArray(typ *T) *T { |
| 1231 | // Do not make an array of type unknown[]. Follow Postgres' behavior and convert |
| 1232 | // this to type string[]. Likewise, Any does not have an array type, so treat it |
| 1233 | // as an array of strings. |
| 1234 | if typ.Family() == UnknownFamily || |
| 1235 | (typ.Family() == AnyFamily && typ.Oid() == oid.T_any) { |
| 1236 | typ = String |
| 1237 | } |
| 1238 | arr := &T{InternalType: InternalType{ |
| 1239 | Family: ArrayFamily, |
| 1240 | Oid: CalcArrayOid(typ), |
| 1241 | ArrayContents: typ, |
| 1242 | Locale: &emptyLocale, |
| 1243 | }} |
| 1244 | return arr |
| 1245 | } |
| 1246 | |
| 1247 | // MakeTuple constructs a new instance of a TupleFamily type with the given |
| 1248 | // field types (some/all of which may be other TupleFamily types). |
no test coverage detected
searching dependent graphs…