uptrace / bun

SQL-first Golang ORM
https://bun.uptrace.dev
BSD 2-Clause "Simplified" License
3.65k stars 221 forks source link

Postgresql text[] arrays not supported for array or type struct tags #889

Closed genslein closed 1 year ago

genslein commented 1 year ago

I am trying to migrate an existing Postgresql database table that uses a field in Postgresql as text[]. However when using the Bun.BaseModel and tags this does defaults to either bytea, __varchar, or __text in the Migration of the table.

I've traced this back to this mapping here: https://github.com/uptrace/bun/blob/master/schema/sqltype.go#L45

I've tried the following to get the generation correct but bun seems to only want to recognize usage from varchar. Any way this can be supported properly for Postgresql Data types in the dialect?

https://github.com/uptrace/bun/blob/master/dialect/pgdialect/sqltype.go#L32

Tags []string `bun:",array"`
...
Tags []string `bun:"type:text[]"`
...
Tags []string `bun:",varchar[]"`
genslein commented 1 year ago

image nvm DBeaver was acting strange with the typing