@@ -63,16 +63,76 @@ func TestColumnsIgnoresPrivateFields(t *testing.T) {
6363 assert .EqualValues (t , []string {"Age" }, cols )
6464}
6565
66- func TestColumnsAddsComplexTypesWhenStructTag (t * testing.T ) {
66+ func TestColumnsAddsComplexTypesWhenNoStructTag (t * testing.T ) {
6767 type person struct {
6868 Address struct {
6969 Street string
70+ }
71+ }
72+
73+ cols , err := Columns (& person {})
74+ assert .NoError (t , err )
75+ assert .EqualValues (t , []string {"Street" }, cols )
76+ }
77+
78+ func TestColumnsAddsComplexTypesWhenStructTag (t * testing.T ) {
79+ type person struct {
80+ Address struct {
81+ Street string `db:"address.street"`
82+ }
83+ }
84+
85+ cols , err := Columns (& person {})
86+ assert .NoError (t , err )
87+ assert .EqualValues (t , []string {"address.street" }, cols )
88+ }
89+
90+ func TestColumnsDoesNotAddStructTag (t * testing.T ) {
91+ type person struct {
92+ Address struct {
93+ Street string `db:"address.street"`
7094 } `db:"address"`
7195 }
7296
7397 cols , err := Columns (& person {})
7498 assert .NoError (t , err )
75- assert .EqualValues (t , []string {"address" }, cols )
99+ assert .EqualValues (t , []string {"address.street" }, cols )
100+ }
101+
102+ func TestColumnsStrictAddsComplexTypesWhenStructTag (t * testing.T ) {
103+ type person struct {
104+ Address struct {
105+ Street string `db:"address.street"`
106+ }
107+ }
108+
109+ cols , err := ColumnsStrict (& person {})
110+ assert .NoError (t , err )
111+ assert .EqualValues (t , []string {"address.street" }, cols )
112+ }
113+
114+ func TestColumnsStrictDoesNotAddComplexTypesWhenNoStructTag (t * testing.T ) {
115+ type person struct {
116+ Address struct {
117+ Street string
118+ }
119+ }
120+
121+ cols , err := ColumnsStrict (& person {})
122+ assert .NoError (t , err )
123+ assert .EqualValues (t , []string {}, cols )
124+ }
125+
126+ func TestColumnsStrictAddsComplexTypesRegardlessOfStructTag (t * testing.T ) {
127+ type person struct {
128+ Address struct {
129+ Street string `db:"address.street"`
130+ } `db:"-"`
131+ }
132+
133+ cols , err := ColumnsStrict (& person {})
134+ assert .NoError (t , err )
135+ assert .EqualValues (t , []string {"address.street" }, cols )
76136}
77137
78138func TestColumnsIgnoresComplexTypesWhenNoStructTag (t * testing.T ) {
@@ -84,7 +144,7 @@ func TestColumnsIgnoresComplexTypesWhenNoStructTag(t *testing.T) {
84144
85145 cols , err := Columns (& person {})
86146 assert .NoError (t , err )
87- assert .EqualValues (t , []string {}, cols )
147+ assert .EqualValues (t , []string {"Street" }, cols )
88148}
89149
90150func TestColumnsExcludesFields (t * testing.T ) {
0 commit comments