bun icon indicating copy to clipboard operation
bun copied to clipboard

how to set jsonb type default value with content

Open denggj28 opened this issue 3 years ago • 2 comments

Version: 1.1.7

I want to set a jsonb default, like:

{ title: 'title', token: 'token' }

when I define a model:

Field map[string]interface{} `bun:"field,nullzero,notnull,type:jsonb,default:'{ \"title\": \"title\", \"token\": \"token\"}'" json:"field"`

but show me a warn:

WARN: bun: 2022/07/31 23:46:02 Model.Field has unknown tag option: "title"
WARN: bun: 2022/07/31 23:46:02 Model.Field has unknown tag option: "token"

denggj28 avatar Jul 31 '22 16:07 denggj28

Looks like https://github.com/uptrace/bun/tree/master/internal/tagparser should be improved to support more complex values.

vmihailenco avatar Aug 01 '22 05:08 vmihailenco

I'll pick it up. also faced this problem

mmavka avatar Apr 15 '24 07:04 mmavka