@@ -412,7 +412,7 @@ func testQueryWithContext(
412
412
require .NoError (err , "Unexpected error for query %s: %s" , q , err )
413
413
414
414
if expected != nil {
415
- checkResults (t , harness , expected , expectedCols , sch , rows , q , e , wrapBehavior )
415
+ checkResults (t , ctx , harness , expected , expectedCols , sch , rows , q , e , wrapBehavior )
416
416
}
417
417
418
418
require .Equal (
@@ -455,7 +455,7 @@ func TestQueryWithIndexCheck(t *testing.T, ctx *sql.Context, e QueryEngine, harn
455
455
require .NoError (err , "Unexpected error for query %s: %s" , q , err )
456
456
457
457
if expected != nil {
458
- CheckResults (t , harness , expected , expectedCols , sch , rows , q , e )
458
+ CheckResults (ctx , t , harness , expected , expectedCols , sch , rows , q , e )
459
459
}
460
460
461
461
require .Equal (
@@ -514,41 +514,22 @@ func TestPreparedQueryWithContext(t *testing.T, ctx *sql.Context, e QueryEngine,
514
514
515
515
if expected != nil {
516
516
// TODO fix expected cols for prepared?
517
- CheckResults (t , h , expected , expectedCols , sch , rows , q , e )
517
+ CheckResults (ctx , t , h , expected , expectedCols , sch , rows , q , e )
518
518
}
519
519
520
520
require .Equal (0 , ctx .Memory .NumCaches ())
521
521
validateEngine (t , ctx , h , e )
522
522
}
523
523
524
- func CheckResults (
525
- t * testing.T ,
526
- h Harness ,
527
- expected []sql.Row ,
528
- expectedCols []* sql.Column ,
529
- sch sql.Schema ,
530
- rows []sql.Row ,
531
- q string ,
532
- e QueryEngine ,
533
- ) {
534
- checkResults (t , h , expected , expectedCols , sch , rows , q , e , queries .WrapBehavior_Unwrap )
524
+ func CheckResults (ctx * sql.Context , t * testing.T , h Harness , expected []sql.Row , expectedCols []* sql.Column , sch sql.Schema , rows []sql.Row , q string , e QueryEngine ) {
525
+ checkResults (t , ctx , h , expected , expectedCols , sch , rows , q , e , queries .WrapBehavior_Unwrap )
535
526
}
536
527
537
- func checkResults (
538
- t * testing.T ,
539
- h Harness ,
540
- expected []sql.Row ,
541
- expectedCols []* sql.Column ,
542
- sch sql.Schema ,
543
- rows []sql.Row ,
544
- q string ,
545
- e QueryEngine ,
546
- wrapBehavior queries.WrapBehavior ,
547
- ) {
528
+ func checkResults (t * testing.T , ctx * sql.Context , h Harness , expected []sql.Row , expectedCols []* sql.Column , sch sql.Schema , rows []sql.Row , q string , e QueryEngine , wrapBehavior queries.WrapBehavior ) {
548
529
if reh , ok := h .(ResultEvaluationHarness ); ok {
549
530
reh .EvaluateQueryResults (t , expected , expectedCols , sch , rows , q , wrapBehavior )
550
531
} else {
551
- checkResultsDefault (t , expected , expectedCols , sch , rows , q , e , wrapBehavior )
532
+ checkResultsDefault (t , ctx , expected , expectedCols , sch , rows , q , e , wrapBehavior )
552
533
}
553
534
}
554
535
@@ -688,7 +669,7 @@ type CustomValueValidator interface {
688
669
// toSQL converts the given expected value into appropriate type of given column.
689
670
// |isZeroTime| is true if the query is any `SHOW` statement, except for `SHOW EVENTS`.
690
671
// This is set earlier in `checkResult()` method.
691
- func toSQL (c * sql.Column , expected any , isZeroTime bool ) (any , error ) {
672
+ func toSQL (ctx * sql. Context , c * sql.Column , expected any , isZeroTime bool ) (any , error ) {
692
673
_ , isTime := expected .(time.Time )
693
674
_ , isStr := expected .(string )
694
675
// cases where we don't want the result value to be converted
@@ -705,16 +686,7 @@ func toSQL(c *sql.Column, expected any, isZeroTime bool) (any, error) {
705
686
// don't implement ResultEvaluationHarness. All numerical values are widened to their widest type before comparison.
706
687
// Based on the value of |unwrapValues|, this either normalized wrapped values by unwrapping them, or replaces them
707
688
// with their hash so the test caller can assert that the values are wrapped and have a certain hash.
708
- func checkResultsDefault (
709
- t * testing.T ,
710
- expected []sql.Row ,
711
- expectedCols []* sql.Column ,
712
- sch sql.Schema ,
713
- rows []sql.Row ,
714
- q string ,
715
- e QueryEngine ,
716
- wrapBehavior queries.WrapBehavior ,
717
- ) {
689
+ func checkResultsDefault (t * testing.T , ctx * sql.Context , expected []sql.Row , expectedCols []* sql.Column , sch sql.Schema , rows []sql.Row , q string , e QueryEngine , wrapBehavior queries.WrapBehavior ) {
718
690
widenedRows := WidenRows (t , sch , rows )
719
691
widenedExpected := WidenRows (t , sch , expected )
720
692
@@ -804,7 +776,7 @@ func checkResultsDefault(
804
776
} else {
805
777
// this attempts to do what `rowToSQL()` method in `handler.go` on expected row
806
778
// because over the wire values gets converted to SQL values depending on the column types.
807
- convertedExpected , err := toSQL (sch [j ], widenedExpected [i ][j ], setZeroTime )
779
+ convertedExpected , err := toSQL (ctx , sch [j ], widenedExpected [i ][j ], setZeroTime )
808
780
require .NoError (t , err )
809
781
widenedExpected [i ][j ] = convertedExpected
810
782
}
@@ -1120,7 +1092,7 @@ func AssertWarningAndTestQuery(
1120
1092
}
1121
1093
1122
1094
if ! skipResultsCheck {
1123
- CheckResults (t , harness , expected , expectedCols , sch , rows , query , e )
1095
+ CheckResults (ctx , t , harness , expected , expectedCols , sch , rows , query , e )
1124
1096
}
1125
1097
validateEngine (t , ctx , harness , e )
1126
1098
}
0 commit comments