@@ -19,7 +19,7 @@ func initMocks(t *testing.T) (*gomock.Controller, *mocks.MockSchemeCommenter) {
1919func TestMakeCommentsWithTableName (t * testing.T ) {
2020 type Ballot struct {
2121 //nolint
22- tableName struct {} `pg:"ballots" comment:"Ballot table"`
22+ tableName struct {} `comment:"Ballot table" pg:"ballots "`
2323 Ballot string `json:"ballot"`
2424 }
2525
@@ -76,7 +76,7 @@ func TestMakeCommentsFieldWithPgComment(t *testing.T) {
7676 type Ballot struct {
7777 //nolint
7878 tableName struct {} `pg:"ballots"`
79- Ballot string `json:"ballot" comment:"This is field comment"`
79+ Ballot string `comment:"This is field comment" json:"ballot "`
8080 }
8181
8282 mockCtrl , mockSC := initMocks (t )
@@ -101,22 +101,22 @@ func TestMakeCommentsFieldWithPgComment(t *testing.T) {
101101func TestMakeCommentsWithTableNameAndFieldsWithPgComment (t * testing.T ) {
102102 type Ballot struct {
103103 //nolint
104- tableName struct {} `pg:"ballots" comment:"Ballot table"`
105- CreatedAt int64 `json:"-" comment:"This is field comment"`
106- UpdatedAt int64 `json:"-" comment:"This is field comment"`
107- Network string `json:"network" pg:",pk" comment:"This is field comment "`
108- Hash string `json:"hash" pg:",pk" comment:"This is field comment "`
109- Branch string `json:"branch" comment:"This is field comment"`
110- Status string `json:"status" comment:"This is field comment"`
111- Kind string `json:"kind" comment:"This is field comment"`
112- Signature string `json:"signature" comment:"This is field comment"`
113- Protocol string `json:"protocol" comment:"This is field comment"`
114- Level uint64 `json:"level" comment:"This is field comment"`
115- Errors interface {} `json:"errors,omitempty" pg:"type:jsonb" comment:"This is field comment "`
116- ExpirationLevel * uint64 `json:"expiration_level" comment:"This is field comment"`
117- Raw interface {} `json:"raw,omitempty" pg:"type:jsonb" comment:"This is field comment "`
118- Ballot string `json:"ballot" comment:"This is field comment"`
119- Period int64 `json:"period" comment:"This is field comment"`
104+ tableName struct {} `comment:"Ballot table" pg:"ballots "`
105+ CreatedAt int64 `comment:"This is field comment" json:"- "`
106+ UpdatedAt int64 `comment:"This is field comment" json:"- "`
107+ Network string `comment:"This is field comment" json:"network" pg:",pk "`
108+ Hash string `comment:"This is field comment" json:"hash" pg:",pk "`
109+ Branch string `comment:"This is field comment" json:"branch "`
110+ Status string `comment:"This is field comment" json:"status "`
111+ Kind string `comment:"This is field comment" json:"kind "`
112+ Signature string `comment:"This is field comment" json:"signature "`
113+ Protocol string `comment:"This is field comment" json:"protocol "`
114+ Level uint64 `comment:"This is field comment" json:"level "`
115+ Errors interface {} `comment:"This is field comment" json:"errors,omitempty" pg:"type:jsonb"`
116+ ExpirationLevel * uint64 `comment:"This is field comment" json:"expiration_level "`
117+ Raw interface {} `comment:"This is field comment" json:"raw,omitempty" pg:"type:jsonb"`
118+ Ballot string `comment:"This is field comment" json:"ballot "`
119+ Period int64 `comment:"This is field comment" json:"period "`
120120 }
121121
122122 mockCtrl , mockSC := initMocks (t )
@@ -148,8 +148,8 @@ func TestMakeCommentsWithTableNameAndFieldsWithPgComment(t *testing.T) {
148148func TestMakeCommentsWithMultipleModels (t * testing.T ) {
149149 type Ballot struct {
150150 //nolint
151- tableName struct {} `pg:"ballots" comment:"This multiple table name comment"`
152- Ballot string `json:"ballot" comment:"This is multiple field comment"`
151+ tableName struct {} `comment:"This multiple table name comment" pg:"ballots "`
152+ Ballot string `comment:"This is multiple field comment" json:"ballot "`
153153 }
154154
155155 mockCtrl , mockSC := initMocks (t )
@@ -182,8 +182,8 @@ func TestMakeCommentsWithMultipleModels(t *testing.T) {
182182func TestMakeCommentsWithMultipleModelsByPointers (t * testing.T ) {
183183 type Ballot struct {
184184 //nolint
185- tableName struct {} `pg:"ballots" comment:"This multiple table name comment"`
186- Ballot string `json:"ballot" comment:"This is multiple field comment"`
185+ tableName struct {} `comment:"This multiple table name comment" pg:"ballots "`
186+ Ballot string `comment:"This is multiple field comment" json:"ballot "`
187187 }
188188
189189 mockCtrl , mockSC := initMocks (t )
@@ -217,7 +217,7 @@ func TestMakeCommentsIgnoreFieldWithPgHyphen(t *testing.T) {
217217 type Ballot struct {
218218 //nolint
219219 tableName struct {} `pg:"ballots"`
220- Ballot string `json:"ballot" pg:"-" comment:"This is field comment"`
220+ Ballot string `comment:"This is field comment" json:"ballot" pg:"- "`
221221 }
222222
223223 mockCtrl , mockSC := initMocks (t )
@@ -242,7 +242,7 @@ func TestMakeCommentsIgnoreFieldsWithEmptyComment(t *testing.T) {
242242 type Ballot struct {
243243 //nolint
244244 tableName struct {} `pg:"ballots"`
245- Ballot string `json:"ballot" comment:" "`
245+ Ballot string `comment:"" json:"ballot "`
246246 }
247247
248248 mockCtrl , mockSC := initMocks (t )
@@ -299,16 +299,16 @@ func TestMakeCommentsIgnoreNoModels(t *testing.T) {
299299
300300func TestMakeCommentsWithStructCompositionAndCorrectOrder (t * testing.T ) {
301301 type Operation struct {
302- CreatedAt int64 `json:"-" comment:"Date of creation in seconds since UNIX epoch."`
303- UpdatedAt int64 `json:"-" comment:"Date of last update in seconds since UNIX epoch."`
304- Network string `json:" network" pg:",pk" comment:"Identifies belonging network. "`
302+ CreatedAt int64 `comment:"Date of creation in seconds since UNIX epoch." json:"- "`
303+ UpdatedAt int64 `comment:"Date of last update in seconds since UNIX epoch." json:"- "`
304+ Network string `comment:"Identifies belonging network." json:"network" pg:",pk "`
305305 }
306306
307307 type Ballot struct {
308308 //nolint
309- tableName struct {} `pg:"ballots" comment:"This table name comment"`
309+ tableName struct {} `comment:"This table name comment" pg:"ballots "`
310310 Operation
311- Ballot string `json:"ballot" comment:"This is field comment"`
311+ Ballot string `comment:"This is field comment" json:"ballot "`
312312 }
313313
314314 mockCtrl , mockSC := initMocks (t )
@@ -360,24 +360,24 @@ func TestMakeCommentsWithStructCompositionAndCorrectOrder(t *testing.T) {
360360
361361func TestMakeCommentsWithDeepStructComposition (t * testing.T ) {
362362 type CreatedMetadata struct {
363- CreatedAt int64 `json:"-" comment:"Date of creation in seconds since UNIX epoch."`
363+ CreatedAt int64 `comment:"Date of creation in seconds since UNIX epoch." json:"- "`
364364 }
365365
366366 type UpdatedMetadata struct {
367367 CreatedMetadata
368- UpdatedAt int64 `json:"-" comment:"Date of last update in seconds since UNIX epoch."`
368+ UpdatedAt int64 `comment:"Date of last update in seconds since UNIX epoch." json:"- "`
369369 }
370370
371371 type Operation struct {
372372 UpdatedMetadata
373- Network string `json:" network" pg:",pk" comment:"Identifies belonging network. "`
373+ Network string `comment:"Identifies belonging network." json:"network" pg:",pk "`
374374 }
375375
376376 type Ballot struct {
377377 //nolint
378- tableName struct {} `pg:"ballots" comment:"This table name comment"`
378+ tableName struct {} `comment:"This table name comment" pg:"ballots "`
379379 Operation
380- Ballot string `json:"ballot" comment:"This is field comment"`
380+ Ballot string `comment:"This is field comment" json:"ballot "`
381381 }
382382
383383 mockCtrl , mockSC := initMocks (t )
@@ -430,17 +430,17 @@ func TestMakeCommentsWithDeepStructComposition(t *testing.T) {
430430func TestMakeCommentsWithStructCompositionErrorOnEmbeddedTableName (t * testing.T ) {
431431 type Operation struct {
432432 //nolint
433- tableName struct {} `pg:"operation" comment:"This embedded type tableName comment."`
434- CreatedAt int64 `json:"-" comment:"Date of creation in seconds since UNIX epoch."`
435- UpdatedAt int64 `json:"-" comment:"Date of last update in seconds since UNIX epoch."`
436- Network string `json:" network" pg:",pk" comment:"Identifies belonging network. "`
433+ tableName struct {} `comment:"This embedded type tableName comment." pg:"operation "`
434+ CreatedAt int64 `comment:"Date of creation in seconds since UNIX epoch." json:"- "`
435+ UpdatedAt int64 `comment:"Date of last update in seconds since UNIX epoch." json:"- "`
436+ Network string `comment:"Identifies belonging network." json:"network" pg:",pk "`
437437 }
438438
439439 type Ballot struct {
440440 //nolint
441- tableName struct {} `pg:"ballots" comment:"This table name comment"`
441+ tableName struct {} `comment:"This table name comment" pg:"ballots "`
442442 Operation
443- Ballot string `json:"ballot" comment:"This is field comment"`
443+ Ballot string `comment:"This is field comment" json:"ballot "`
444444 }
445445
446446 mockCtrl , mockSC := initMocks (t )
@@ -464,10 +464,10 @@ func TestMakeCommentsWithStructCompositionErrorOnEmbeddedTableName(t *testing.T)
464464
465465func TestMakeCommentsWithBunBaseModel (t * testing.T ) {
466466 type Operation struct {
467- bun.BaseModel `pg:"-" bun:"table:operation" comment:"This is bun comment."`
468- CreatedAt int64 `json:"-" comment:"Date of creation in seconds since UNIX epoch."`
469- UpdatedAt int64 `json:"-" comment:"Date of last update in seconds since UNIX epoch."`
470- Network string `json:"network" bun:",pk" comment:"Identifies belonging network."`
467+ bun.BaseModel `bun:"table:operation" comment:"This is bun comment." pg:"- "`
468+ CreatedAt int64 `comment:"Date of creation in seconds since UNIX epoch." json:"- "`
469+ UpdatedAt int64 `comment:"Date of last update in seconds since UNIX epoch." json:"- "`
470+ Network string `bun:",pk" comment:"Identifies belonging network." json:"network "`
471471 }
472472
473473 mockCtrl , mockSC := initMocks (t )
0 commit comments