@@ -2003,7 +2003,8 @@ func TestSelectAll(t *testing.T) {
20032003 }
20042004 type testStruct struct {
20052005 Col1 int64
2006- Col2 float64
2006+ // declaring second column in upper case here to verify SelectAll does case-insensitive matching
2007+ COL2 float64
20072008 Col3 string
20082009 Col4 time.Time
20092010 }
@@ -2087,8 +2088,8 @@ func TestSelectAll(t *testing.T) {
20872088 },
20882089 },
20892090 want : & []testStruct {
2090- {Col1 : 1 , Col2 : 1.1 , Col3 : "value" , Col4 : tm },
2091- {Col1 : 2 , Col2 : 2.2 , Col3 : "value2" , Col4 : tm .Add (24 * time .Hour )},
2091+ {Col1 : 1 , COL2 : 1.1 , Col3 : "value" , Col4 : tm },
2092+ {Col1 : 2 , COL2 : 2.2 , Col3 : "value2" , Col4 : tm .Add (24 * time .Hour )},
20922093 },
20932094 },
20942095 {
@@ -2117,8 +2118,8 @@ func TestSelectAll(t *testing.T) {
21172118 },
21182119 },
21192120 want : & []* testStruct {
2120- {Col1 : 1 , Col2 : 1.1 , Col3 : "value" },
2121- {Col1 : 2 , Col2 : 2.2 , Col3 : "value2" },
2121+ {Col1 : 1 , COL2 : 1.1 , Col3 : "value" },
2122+ {Col1 : 2 , COL2 : 2.2 , Col3 : "value2" },
21222123 }},
21232124 {
21242125 name : "success: when spanner row contains more columns than declared in Go struct but called WithLenient" ,
@@ -2142,13 +2143,13 @@ func TestSelectAll(t *testing.T) {
21422143 options : []DecodeOptions {WithLenient ()},
21432144 },
21442145 want : & []* testStruct {
2145- {Col1 : 1 , Col2 : 1.1 , Col3 : "value" , Col4 : tm },
2146+ {Col1 : 1 , COL2 : 1.1 , Col3 : "value" , Col4 : tm },
21462147 },
21472148 },
21482149 {
21492150 name : "success: using prefilled destination should append to the destination" ,
21502151 args : args {
2151- destination : & []* testStruct {{Col1 : 3 , Col2 : 3.3 , Col3 : "value3" }},
2152+ destination : & []* testStruct {{Col1 : 3 , COL2 : 3.3 , Col3 : "value3" }},
21522153 mock : func (mockIterator * mockRowIterator ) {
21532154 mockIterator .On ("Next" ).Once ().Return (& Row {
21542155 []* sppb.StructType_Field {
@@ -2171,14 +2172,14 @@ func TestSelectAll(t *testing.T) {
21712172 },
21722173 },
21732174 want : & []* testStruct {
2174- {Col1 : 3 , Col2 : 3.3 , Col3 : "value3" },
2175- {Col1 : 1 , Col2 : 1.1 , Col3 : "value" },
2176- {Col1 : 2 , Col2 : 2.2 , Col3 : "value2" },
2175+ {Col1 : 3 , COL2 : 3.3 , Col3 : "value3" },
2176+ {Col1 : 1 , COL2 : 1.1 , Col3 : "value" },
2177+ {Col1 : 2 , COL2 : 2.2 , Col3 : "value2" },
21772178 }},
21782179 {
21792180 name : "failure: in case of error destination will have the partial result" ,
21802181 args : args {
2181- destination : & []* testStruct {{Col1 : 3 , Col2 : 3.3 , Col3 : "value3" }},
2182+ destination : & []* testStruct {{Col1 : 3 , COL2 : 3.3 , Col3 : "value3" }},
21822183 mock : func (mockIterator * mockRowIterator ) {
21832184 mockIterator .On ("Next" ).Once ().Return (& Row {
21842185 []* sppb.StructType_Field {
@@ -2194,15 +2195,15 @@ func TestSelectAll(t *testing.T) {
21942195 },
21952196 },
21962197 want : & []* testStruct {
2197- {Col1 : 3 , Col2 : 3.3 , Col3 : "value3" },
2198- {Col1 : 1 , Col2 : 1.1 , Col3 : "value" },
2198+ {Col1 : 3 , COL2 : 3.3 , Col3 : "value3" },
2199+ {Col1 : 1 , COL2 : 1.1 , Col3 : "value" },
21992200 },
22002201 wantErr : true ,
22012202 },
22022203 {
22032204 name : "failure: when spanner row contains more columns than declared in Go struct" ,
22042205 args : args {
2205- destination : & []* testStruct {{Col1 : 3 , Col2 : 3.3 , Col3 : "value3" }},
2206+ destination : & []* testStruct {{Col1 : 3 , COL2 : 3.3 , Col3 : "value3" }},
22062207 mock : func (mockIterator * mockRowIterator ) {
22072208 mockIterator .On ("Next" ).Once ().Return (& Row {
22082209 []* sppb.StructType_Field {
@@ -2219,7 +2220,7 @@ func TestSelectAll(t *testing.T) {
22192220 },
22202221 },
22212222 want : & []* testStruct {
2222- {Col1 : 3 , Col2 : 3.3 , Col3 : "value3" },
2223+ {Col1 : 3 , COL2 : 3.3 , Col3 : "value3" },
22232224 },
22242225 wantErr : true ,
22252226 },
0 commit comments