From 94b054e9e9507c517e0c8e3e3b13c822419258b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20A=CC=81lvarez?= Date: Sat, 22 Mar 2025 12:59:39 +0100 Subject: [PATCH] Add support for arrays of type string, int and float --- internal/entimport/postgres.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/entimport/postgres.go b/internal/entimport/postgres.go index 744e414..39c3645 100644 --- a/internal/entimport/postgres.go +++ b/internal/entimport/postgres.go @@ -79,8 +79,20 @@ func (p *Postgres) field(column *schema.Column) (f ent.Field, err error) { f = p.convertSerial(typ, name) case *postgres.UUIDType: f = field.UUID(name, uuid.New()) + case *postgres.ArrayType: + switch typ := typ.Type.(type) { + case *schema.IntegerType: + f = field.Ints(name) + case *schema.DecimalType: + f = field.Floats(name) + case *schema.StringType: + f = field.Strings(name) + default: + return nil, fmt.Errorf("entimport: unsupported arary %+v %T for column %v", typ, typ, column.Name) + } + default: - return nil, fmt.Errorf("entimport: unsupported type %q for column %v", typ, column.Name) + return nil, fmt.Errorf("entimport: unsupported type %T for column %v", typ, column.Name) } applyColumnAttributes(f, column) return f, err