From ebb456a92b4353632a60391548a498ed5c135033 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 7 Feb 2024 13:00:04 +0530 Subject: [PATCH] test: add e2e test for subqueries in fk as well Signed-off-by: Manan Gupta --- go/test/endtoend/vtgate/foreignkey/fk_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/go/test/endtoend/vtgate/foreignkey/fk_test.go b/go/test/endtoend/vtgate/foreignkey/fk_test.go index ef8a67c071f..ff4126387b8 100644 --- a/go/test/endtoend/vtgate/foreignkey/fk_test.go +++ b/go/test/endtoend/vtgate/foreignkey/fk_test.go @@ -170,6 +170,14 @@ func TestUpdateWithFK(t *testing.T) { // Verify the result in u_t2 and u_t3 as well. utils.AssertMatches(t, conn, `select * from u_t2 order by id`, `[[INT64(19) INT64(1234)] [INT64(342) NULL]]`) utils.AssertMatches(t, conn, `select * from u_t3 order by id`, `[[INT64(1) INT64(12)] [INT64(32) INT64(13)]]`) + + // Update with a subquery inside, such that the update is on a foreign key related column. + qr = utils.Exec(t, conn, `update u_t2 set col2 = (select col1 from u_t1 where id = 100) where id = 342`) + assert.EqualValues(t, 1, qr.RowsAffected) + // Verify the result in u_t1, u_t2 and u_t3. + utils.AssertMatches(t, conn, `select * from u_t1 order by id`, `[[INT64(1) INT64(13)] [INT64(10) INT64(12)] [INT64(100) INT64(13)] [INT64(1000) INT64(1234)]]`) + utils.AssertMatches(t, conn, `select * from u_t2 order by id`, `[[INT64(19) INT64(1234)] [INT64(342) INT64(13)]]`) + utils.AssertMatches(t, conn, `select * from u_t3 order by id`, `[[INT64(1) INT64(12)] [INT64(32) INT64(13)]]`) } // TestVstreamForFKBinLog tests that dml queries with fks are written with child row first approach in the binary logs.