@@ -306,9 +306,9 @@ func TestMakeCommentsWithStructCompositionAndCorrectOrder(t *testing.T) {
306306
307307 type Ballot struct {
308308 //nolint
309- tableName struct {} `pg:"ballots" comment:"This multiple table name comment"`
309+ tableName struct {} `pg:"ballots" comment:"This table name comment"`
310310 Operation
311- Ballot string `json:"ballot" comment:"This is multiple field comment"`
311+ Ballot string `json:"ballot" comment:"This is field comment"`
312312 }
313313
314314 mockCtrl , mockSC , ctx := initMocks (t )
@@ -319,7 +319,7 @@ func TestMakeCommentsWithStructCompositionAndCorrectOrder(t *testing.T) {
319319 // Assert prepare
320320 tableNameCall := mockSC .
321321 EXPECT ().
322- MakeTableComment (ctx , "ballots" , "This multiple table name comment" ).
322+ MakeTableComment (ctx , "ballots" , "This table name comment" ).
323323 Times (1 ).
324324 Return (nil )
325325
@@ -346,7 +346,7 @@ func TestMakeCommentsWithStructCompositionAndCorrectOrder(t *testing.T) {
346346
347347 mockSC .
348348 EXPECT ().
349- MakeColumnComment (ctx , "ballots" , "ballot" , "This is multiple field comment" ).
349+ MakeColumnComment (ctx , "ballots" , "ballot" , "This is field comment" ).
350350 After (networkCall ).
351351 Times (1 ).
352352 Return (nil )
@@ -375,9 +375,9 @@ func TestMakeCommentsWithDeepStructComposition(t *testing.T) {
375375
376376 type Ballot struct {
377377 //nolint
378- tableName struct {} `pg:"ballots" comment:"This multiple table name comment"`
378+ tableName struct {} `pg:"ballots" comment:"This table name comment"`
379379 Operation
380- Ballot string `json:"ballot" comment:"This is multiple field comment"`
380+ Ballot string `json:"ballot" comment:"This is field comment"`
381381 }
382382
383383 mockCtrl , mockSC , ctx := initMocks (t )
@@ -388,7 +388,7 @@ func TestMakeCommentsWithDeepStructComposition(t *testing.T) {
388388 // Assert prepare
389389 tableNameCall := mockSC .
390390 EXPECT ().
391- MakeTableComment (ctx , "ballots" , "This multiple table name comment" ).
391+ MakeTableComment (ctx , "ballots" , "This table name comment" ).
392392 Times (1 ).
393393 Return (nil )
394394
@@ -415,7 +415,7 @@ func TestMakeCommentsWithDeepStructComposition(t *testing.T) {
415415
416416 mockSC .
417417 EXPECT ().
418- MakeColumnComment (ctx , "ballots" , "ballot" , "This is multiple field comment" ).
418+ MakeColumnComment (ctx , "ballots" , "ballot" , "This is field comment" ).
419419 After (networkCall ).
420420 Times (1 ).
421421 Return (nil )
@@ -426,3 +426,38 @@ func TestMakeCommentsWithDeepStructComposition(t *testing.T) {
426426 // Assert
427427 assert .Empty (t , err )
428428}
429+
430+ func TestMakeCommentsWithStructCompositionErrorOnEmbeddedTableName (t * testing.T ) {
431+ type Operation struct {
432+ //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."`
437+ }
438+
439+ type Ballot struct {
440+ //nolint
441+ tableName struct {} `pg:"ballots" comment:"This table name comment"`
442+ Operation
443+ Ballot string `json:"ballot" comment:"This is field comment"`
444+ }
445+
446+ mockCtrl , mockSC , ctx := initMocks (t )
447+ defer mockCtrl .Finish ()
448+
449+ model := Ballot {}
450+
451+ // Assert prepare
452+ mockSC .
453+ EXPECT ().
454+ MakeTableComment (ctx , "ballots" , "This table name comment" ).
455+ Times (1 ).
456+ Return (nil )
457+
458+ // Act
459+ err := MakeComments (ctx , mockSC , model )
460+
461+ // Assert
462+ assert .Error (t , err , "Embedded type must not have tableName field." )
463+ }
0 commit comments