uptrace / bun

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

In v1.2, about 'unique' tag option in embedded structures #981

Open liut opened 2 months ago

liut commented 2 months ago

After updated to v1.2.1 today, I noticed that my unit tests which used to pass are now failing. It seems like the unique tag option in nested structures has become ineffective, and this issue is present in v1.2.0 as well.

My Go version is v1.22.0, with PostgreSQL 15, and tested in macOS 14.

More detail in https://github.com/cupogo/andvari/blob/main/stores/pgx/z0_main_test.go

type Clause struct {
    comm.BaseModel `bun:"table:cms_clause,alias:c" json:"-"`

    comm.DefaultModel

    ClauseBasic
    comm.MetaField
}

type ClauseBasic struct {
    Slug  string   `bun:"slug,notnull,type:name,unique" json:"slug" `
    Text  string   `bun:"text,notnull,type:text" form:"text" json:"text" `
    Cates []string `bun:"cates,notnull,type:jsonb" form:"cats" json:"cats" `
}

WX20240423-192758@2x

I've searched through the most recent change history and still couldn't pinpoint the specific reason.

dnaeon commented 1 month ago

Seeing a similar behaviour in v1.2.1.

Any workarounds or an expected fix about this one? Thanks!