Dropped field value(s) on slice model insert
Author: NyaaaWhatsUpDocCreated Jul 20, 2026Updated Sep 12, 2026
Labelsstale
in query_insert.go when you determine which fields you'll range over to insert values (and which you'll instead add to RETURNING clause), you filter out fields for insert based only on the first slice element value. see: https://github.com/uptrace/bun/blob/44c54f24205e2d10c6cff6d0541ad09f59afcf4c/query_insert.go#L436
so then any later models after the first element in the slice that actually have a non-zero value set for that field won't have it inserted. which is obviously quite a serious issue as it means data then doesn't get inserted in the database!
Source: uptrace/bun