diff --git a/go/sqltypes/proto3.go b/go/sqltypes/proto3.go index a9c66c45a4c..12e73aac5ca 100644 --- a/go/sqltypes/proto3.go +++ b/go/sqltypes/proto3.go @@ -120,7 +120,7 @@ func Proto3ToResult(qr *querypb.QueryResult) *Result { Fields: qr.Fields, RowsAffected: qr.RowsAffected, InsertID: qr.InsertId, - InsertIDChanged: qr.InsertIdChanged, + InsertIDChanged: qr.InsertIdChanged || qr.InsertId != 0, Rows: proto3ToRows(qr.Fields, qr.Rows), Info: qr.Info, SessionStateChanges: qr.SessionStateChanges, diff --git a/go/sqltypes/proto3_test.go b/go/sqltypes/proto3_test.go index 5e0bffd2a73..61674b2d1e4 100644 --- a/go/sqltypes/proto3_test.go +++ b/go/sqltypes/proto3_test.go @@ -39,9 +39,10 @@ func TestResult(t *testing.T) { Type: Float64, }} sqlResult := &Result{ - Fields: fields, - InsertID: 1, - RowsAffected: 2, + Fields: fields, + InsertID: 1, + InsertIDChanged: true, + RowsAffected: 2, Rows: [][]Value{{ TestValue(VarChar, "aa"), TestValue(Int64, "1"), @@ -53,9 +54,10 @@ func TestResult(t *testing.T) { }}, } p3Result := &querypb.QueryResult{ - Fields: fields, - InsertId: 1, - RowsAffected: 2, + Fields: fields, + InsertId: 1, + InsertIdChanged: true, + RowsAffected: 2, Rows: []*querypb.Row{{ Lengths: []int64{2, 1, 1}, Values: []byte("aa12"), @@ -105,18 +107,20 @@ func TestResults(t *testing.T) { Type: Float64, }} sqlResults := []Result{{ - Fields: fields1, - InsertID: 1, - RowsAffected: 2, + Fields: fields1, + InsertID: 1, + InsertIDChanged: true, + RowsAffected: 2, Rows: [][]Value{{ TestValue(VarChar, "aa"), TestValue(Int64, "1"), TestValue(Float64, "2"), }}, }, { - Fields: fields2, - InsertID: 3, - RowsAffected: 4, + Fields: fields2, + InsertID: 3, + InsertIDChanged: true, + RowsAffected: 4, Rows: [][]Value{{ TestValue(VarChar, "bb"), TestValue(Int64, "3"), @@ -124,17 +128,19 @@ func TestResults(t *testing.T) { }}, }} p3Results := []*querypb.QueryResult{{ - Fields: fields1, - InsertId: 1, - RowsAffected: 2, + Fields: fields1, + InsertId: 1, + InsertIdChanged: true, + RowsAffected: 2, Rows: []*querypb.Row{{ Lengths: []int64{2, 1, 1}, Values: []byte("aa12"), }}, }, { - Fields: fields2, - InsertId: 3, - RowsAffected: 4, + Fields: fields2, + InsertId: 3, + InsertIdChanged: true, + RowsAffected: 4, Rows: []*querypb.Row{{ Lengths: []int64{2, 1, 1}, Values: []byte("bb34"), @@ -176,9 +182,10 @@ func TestQueryReponses(t *testing.T) { queryResponses := []QueryResponse{ { QueryResult: &Result{ - Fields: fields1, - InsertID: 1, - RowsAffected: 2, + Fields: fields1, + InsertID: 1, + InsertIDChanged: true, + RowsAffected: 2, Rows: [][]Value{{ TestValue(VarChar, "aa"), TestValue(Int64, "1"), @@ -188,9 +195,10 @@ func TestQueryReponses(t *testing.T) { QueryError: nil, }, { QueryResult: &Result{ - Fields: fields2, - InsertID: 3, - RowsAffected: 4, + Fields: fields2, + InsertID: 3, + InsertIDChanged: true, + RowsAffected: 4, Rows: [][]Value{{ TestValue(VarChar, "bb"), TestValue(Int64, "3"), @@ -208,9 +216,10 @@ func TestQueryReponses(t *testing.T) { { Error: nil, Result: &querypb.QueryResult{ - Fields: fields1, - InsertId: 1, - RowsAffected: 2, + Fields: fields1, + InsertId: 1, + InsertIdChanged: true, + RowsAffected: 2, Rows: []*querypb.Row{{ Lengths: []int64{2, 1, 1}, Values: []byte("aa12"), @@ -219,9 +228,10 @@ func TestQueryReponses(t *testing.T) { }, { Error: nil, Result: &querypb.QueryResult{ - Fields: fields2, - InsertId: 3, - RowsAffected: 4, + Fields: fields2, + InsertId: 3, + InsertIdChanged: true, + RowsAffected: 4, Rows: []*querypb.Row{{ Lengths: []int64{2, 1, 1}, Values: []byte("bb34"), diff --git a/go/sqltypes/result_test.go b/go/sqltypes/result_test.go index d8075ec0633..d49e184f109 100644 --- a/go/sqltypes/result_test.go +++ b/go/sqltypes/result_test.go @@ -57,8 +57,9 @@ func TestCopy(t *testing.T) { }, { Type: VarChar, }}, - InsertID: 1, - RowsAffected: 2, + InsertID: 1, + InsertIDChanged: true, + RowsAffected: 2, Rows: [][]Value{ {TestValue(Int64, "1"), MakeTrusted(Null, nil)}, {TestValue(Int64, "2"), MakeTrusted(VarChar, nil)}, @@ -76,8 +77,9 @@ func TestTruncate(t *testing.T) { }, { Type: VarChar, }}, - InsertID: 1, - RowsAffected: 2, + InsertID: 1, + InsertIDChanged: true, + RowsAffected: 2, Rows: [][]Value{ {TestValue(Int64, "1"), MakeTrusted(Null, nil)}, {TestValue(Int64, "2"), MakeTrusted(VarChar, nil)}, @@ -95,8 +97,9 @@ func TestTruncate(t *testing.T) { Fields: []*querypb.Field{{ Type: Int64, }}, - InsertID: 1, - RowsAffected: 2, + InsertID: 1, + InsertIDChanged: true, + RowsAffected: 2, Rows: [][]Value{ {TestValue(Int64, "1")}, {TestValue(Int64, "2")}, @@ -305,8 +308,9 @@ func TestAppendResult(t *testing.T) { }, { Type: VarChar, }}, - InsertID: 1, - RowsAffected: 2, + InsertIDChanged: true, + InsertID: 1, + RowsAffected: 2, Rows: [][]Value{ {TestValue(Int64, "2"), MakeTrusted(VarChar, nil)}, {TestValue(Int64, "3"), TestValue(VarChar, "")}, @@ -319,8 +323,9 @@ func TestAppendResult(t *testing.T) { }, { Type: VarChar, }}, - InsertID: 3, - RowsAffected: 4, + InsertID: 3, + InsertIDChanged: true, + RowsAffected: 4, Rows: [][]Value{ {TestValue(Int64, "1"), MakeTrusted(Null, nil)}, }, @@ -332,8 +337,9 @@ func TestAppendResult(t *testing.T) { }, { Type: VarChar, }}, - InsertID: 1, - RowsAffected: 6, + InsertID: 1, + InsertIDChanged: true, + RowsAffected: 6, Rows: [][]Value{ {TestValue(Int64, "1"), MakeTrusted(Null, nil)}, {TestValue(Int64, "2"), MakeTrusted(VarChar, nil)},