1 | #include "catch.hpp" |
2 | #include "duckdb/common/file_system.hpp" |
3 | #include "dbgen.hpp" |
4 | #include "test_helpers.hpp" |
5 | |
6 | using namespace duckdb; |
7 | using namespace std; |
8 | |
9 | TEST_CASE("MonetDB Test: update_with_correlated_subselect.SF-1284791.sql" , "[monetdb]" ) { |
10 | unique_ptr<QueryResult> result; |
11 | DuckDB db(nullptr); |
12 | Connection con(db); |
13 | con.EnableQueryVerification(); |
14 | |
15 | REQUIRE_NO_FAIL(con.Query("create table t1284791b (id2 int, val2 varchar(255))" )); |
16 | REQUIRE_NO_FAIL(con.Query("create table t1284791a (id1 int, val1 varchar(255))" )); |
17 | REQUIRE_NO_FAIL(con.Query("insert into t1284791a values (1,'1')" )); |
18 | REQUIRE_NO_FAIL(con.Query("insert into t1284791b values (1,'2')" )); |
19 | |
20 | REQUIRE_NO_FAIL(con.Query("update t1284791a set val1 = (select val2 from t1284791b where id1 = id2) where id1 in " |
21 | "(select id2 from t1284791b);" )); |
22 | |
23 | result = con.Query("select * from t1284791a" ); |
24 | REQUIRE(CHECK_COLUMN(result, 0, {1})); |
25 | REQUIRE(CHECK_COLUMN(result, 1, {"2" })); |
26 | |
27 | result = con.Query("select * from t1284791b" ); |
28 | REQUIRE(CHECK_COLUMN(result, 0, {1})); |
29 | REQUIRE(CHECK_COLUMN(result, 1, {"2" })); |
30 | |
31 | REQUIRE_NO_FAIL(con.Query("drop table t1284791a;" )); |
32 | REQUIRE_NO_FAIL(con.Query("drop table t1284791b;" )); |
33 | } |
34 | |