@@ -357,3 +357,72 @@ func TestMakeCommentsWithStructCompositionAndCorrectOrder(t *testing.T) {
357357 // Assert
358358 assert .Empty (t , err )
359359}
360+
361+ func TestMakeCommentsWithDeepStructComposition (t * testing.T ) {
362+ type CreatedMetadata struct {
363+ CreatedAt int64 `json:"-" comment:"Date of creation in seconds since UNIX epoch."`
364+ }
365+
366+ type UpdatedMetadata struct {
367+ CreatedMetadata
368+ UpdatedAt int64 `json:"-" comment:"Date of last update in seconds since UNIX epoch."`
369+ }
370+
371+ type Operation struct {
372+ UpdatedMetadata
373+ Network string `json:"network" pg:",pk" comment:"Identifies belonging network."`
374+ }
375+
376+ type Ballot struct {
377+ //nolint
378+ tableName struct {} `pg:"ballots" comment:"This multiple table name comment"`
379+ Operation
380+ Ballot string `json:"ballot" comment:"This is multiple field comment"`
381+ }
382+
383+ mockCtrl , mockSC , ctx := initMocks (t )
384+ defer mockCtrl .Finish ()
385+
386+ model := Ballot {}
387+
388+ // Assert prepare
389+ tableNameCall := mockSC .
390+ EXPECT ().
391+ MakeTableComment (ctx , "ballots" , "This multiple table name comment" ).
392+ Times (1 ).
393+ Return (nil )
394+
395+ createdAtCall := mockSC .
396+ EXPECT ().
397+ MakeColumnComment (ctx , "ballots" , "created_at" , "Date of creation in seconds since UNIX epoch." ).
398+ After (tableNameCall ).
399+ Times (1 ).
400+ Return (nil )
401+
402+ updatedAtCall := mockSC .
403+ EXPECT ().
404+ MakeColumnComment (ctx , "ballots" , "updated_at" , "Date of last update in seconds since UNIX epoch." ).
405+ After (createdAtCall ).
406+ Times (1 ).
407+ Return (nil )
408+
409+ networkCall := mockSC .
410+ EXPECT ().
411+ MakeColumnComment (ctx , "ballots" , "network" , "Identifies belonging network." ).
412+ After (updatedAtCall ).
413+ Times (1 ).
414+ Return (nil )
415+
416+ mockSC .
417+ EXPECT ().
418+ MakeColumnComment (ctx , "ballots" , "ballot" , "This is multiple field comment" ).
419+ After (networkCall ).
420+ Times (1 ).
421+ Return (nil )
422+
423+ // Act
424+ err := MakeComments (ctx , mockSC , model )
425+
426+ // Assert
427+ assert .Empty (t , err )
428+ }
0 commit comments