@@ -122,9 +122,12 @@ type ScriptTestAssertion struct {
122122 // This is checked only if no Expected is defined
123123 ExpectedTag string
124124
125- // ExpectedColNames is used to check the column names returned from the server.
125+ // ExpectedColNames are used to check the column names returned from the server.
126126 ExpectedColNames []string
127127
128+ // ExpectedColTypes are used to check the column types returned from the server.
129+ ExpectedColTypes []id.Type
130+
128131 // CopyFromSTDIN is used to test the COPY FROM STDIN command.
129132 CopyFromStdInFile string
130133}
@@ -274,6 +277,17 @@ func runScript(t *testing.T, ctx context.Context, script ScriptTest, conn *Conne
274277 }
275278 }
276279 }
280+ if assertion .ExpectedColTypes != nil {
281+ fields := rows .FieldDescriptions ()
282+ if assert .Len (t , fields , len (assertion .ExpectedColTypes ),
283+ "columns returned and types expected are not the same length" ) {
284+ for i , colId := range assertion .ExpectedColTypes {
285+ assert .Equal (t , id .Cache ().ToOID (colId .AsId ()), fields [i ].DataTypeOID ,
286+ `"%s" expected type "%s" but received "%s"` , fields [i ].Name ,
287+ colId .TypeName (), id .Type (id .Cache ().ToInternal (fields [i ].DataTypeOID )).TypeName ())
288+ }
289+ }
290+ }
277291
278292 // not an exact match but works well enough for our tests
279293 orderBy := strings .Contains (strings .ToLower (assertion .Query ), "order by" )
0 commit comments