diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 1b799ad0ca..42a8209a9a 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -203,7 +203,7 @@ jobs: - {os: ubuntu-20.04, r: 'release', test-src: 'test-mssql', covr: false, desc: 'SQL Server without covr' } - {os: ubuntu-22.04, r: 'release', test-src: 'test-postgres', covr: true, desc: 'Postgres with covr' } - {os: ubuntu-22.04, r: 'release', test-src: 'test-maria', covr: true, desc: 'MariaDB with covr' } - - {os: ubuntu-22.04, r: 'release', test-src: 'test-mysql-maria', covr: true, desc: 'MySQL with covr' } + - {os: ubuntu-22.04, r: 'release', test-src: 'test-mysql', covr: true, desc: 'MySQL with covr' } - {os: ubuntu-22.04, r: 'release', test-src: 'test-duckdb', covr: true, desc: 'DuckDB with covr' } - {os: ubuntu-22.04, r: 'release', test-src: 'test-sqlite', covr: true, desc: 'SQLite with covr' } # End custom: matrix elements diff --git a/.github/workflows/custom/after-install/action.yml b/.github/workflows/custom/after-install/action.yml index 01ca455836..43629fc852 100644 --- a/.github/workflows/custom/after-install/action.yml +++ b/.github/workflows/custom/after-install/action.yml @@ -20,12 +20,12 @@ runs: mariadb-version: 10.9 - uses: ankane/setup-mysql@v1 - if: env.DM_TEST_SRC == 'test-mysql-maria' + if: env.DM_TEST_SRC == 'test-mysql' with: mysql-version: "8.0" - name: Create database (MariaDB), set it to UTF-8, add time zone info - if: env.DM_TEST_SRC == 'test-maria' || env.DM_TEST_SRC == 'test-mysql-maria' + if: env.DM_TEST_SRC == 'test-maria' || env.DM_TEST_SRC == 'test-mysql' run: | mysql -e "CREATE DATABASE IF NOT EXISTS test; ALTER DATABASE test CHARACTER SET 'utf8'; FLUSH PRIVILEGES;" shell: bash diff --git a/Makefile b/Makefile index 07adf2d81d..08529cbcbf 100644 --- a/Makefile +++ b/Makefile @@ -3,19 +3,19 @@ all: qtest # Quiet tests # Run with make -j $(nproc) -O # or with pmake -qtest: qtest-df qtest-sqlite qtest-postgres qtest-mssql qtest-duckdb qtest-maria +qtest: qtest-df qtest-sqlite qtest-postgres qtest-mssql qtest-duckdb qtest-maria qtest-mysql # Progress tests -test: test-df test-sqlite test-postgres test-mssql test-duckdb test-maria +test: test-df test-sqlite test-postgres test-mssql test-duckdb test-maria test-mysql # Testing with lazytest -ltest: ltest-df ltest-sqlite ltest-postgres ltest-mssql ltest-duckdb ltest-maria +ltest: ltest-df ltest-sqlite ltest-postgres ltest-mssql ltest-duckdb ltest-maria ltest-mysql # Silent testing -stest: stest-df stest-sqlite stest-postgres stest-mssql stest-duckdb stest-maria +stest: stest-df stest-sqlite stest-postgres stest-mssql stest-duckdb stest-maria stest-mysql # Connectivity tests -connect: connect-sqlite connect-postgres connect-mssql connect-duckdb connect-maria +connect: connect-sqlite connect-postgres connect-mssql connect-duckdb connect-maria connect-mysql qtest-%: DM_TEST_SRC=$@ time R -q -e 'options("crayon.enabled" = TRUE); Sys.setenv(TESTTHAT_PARALLEL = FALSE); testthat::test_local(filter = "${DM_TEST_FILTER}")' @@ -32,10 +32,20 @@ ltest-%: connect-%: DM_TEST_SRC=$@ R -q -e 'suppressMessages(pkgload::load_all()); my_test_con()' +db-init-maria: + while ! R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_maria(root = TRUE)$$con, "GRANT ALL ON *.* TO '"'"'compose'"'"'@'"'"'%'"'"';"); DBI::dbExecute(test_src_maria()$$con, "FLUSH PRIVILEGES")'; do sleep 1; done + +db-init-mysql: + while ! R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_mysql(root = TRUE)$$con, "GRANT ALL ON *.* TO '"'"'compose'"'"'@'"'"'%'"'"';"); DBI::dbExecute(test_src_mysql()$$con, "FLUSH PRIVILEGES")'; do sleep 1; done + +db-init-mssql: + while ! R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_mssql(FALSE)$$con, "CREATE DATABASE test")'; do sleep 1; done + +db-init: db-init-maria db-init-mysql db-init-mssql + db-start: - docker-compose up -d --force-recreate - R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_maria(root = TRUE)$$con, "GRANT ALL ON *.* TO '"'"'compose'"'"'@'"'"'%'"'"';"); DBI::dbExecute(test_src_maria()$$con, "FLUSH PRIVILEGES")' - R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_mssql(FALSE)$$con, "CREATE DATABASE test")' + docker-compose up -d --force-recreate --wait + $(MAKE) db-init db-restart: docker-compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index 30b039d1b4..5b44435337 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,10 +6,11 @@ volumes: driver: local maria-db: driver: local + mysql-db: + driver: local services: # https://www.beekeeperstudio.io/blog/how-to-use-mariadb-with-docker mysql: - # FIXME: Still need to add Makefile rules to provision MySQL database container_name: mysql image: mysql environment: @@ -17,6 +18,8 @@ services: MYSQL_DATABASE: test MYSQL_USER: compose MYSQL_PASSWORD: "YourStrong!Passw0rd" + volumes: + - mysql-db:/var/lib/mysql ports: - "3307:3306" maria: diff --git a/tests/testthat/_snaps/mysql.md b/tests/testthat/_snaps/mysql.md new file mode 100644 index 0000000000..d4cf23cee7 --- /dev/null +++ b/tests/testthat/_snaps/mysql.md @@ -0,0 +1,311 @@ +# dummy + + Code + # dummy + +# dm_sql() + + Code + dm_for_filter_df() %>% dm_sql(my_test_con()) + Output + $pre + $pre$tf_1 + CREATE TEMPORARY TABLE `tf_1` ( + `a` INT AUTO_INCREMENT, + `b` VARCHAR(255), + PRIMARY KEY (`a`) + ) + + $pre$tf_2 + CREATE TEMPORARY TABLE `tf_2` ( + `c` VARCHAR(255), + `d` INT, + `e` VARCHAR(255), + `e1` INT, + PRIMARY KEY (`c`) + ) + + $pre$tf_3 + CREATE TEMPORARY TABLE `tf_3` ( + `f` VARCHAR(255), + `f1` INT, + `g` VARCHAR(255), + PRIMARY KEY (`f`, `f1`) + ) + + $pre$tf_4 + CREATE TEMPORARY TABLE `tf_4` ( + `h` VARCHAR(255), + `i` VARCHAR(255), + `j` VARCHAR(255), + `j1` INT, + PRIMARY KEY (`h`) + ) + + $pre$tf_5 + CREATE TEMPORARY TABLE `tf_5` ( + `ww` INT, + `k` INT, + `l` VARCHAR(255), + `m` VARCHAR(255), + PRIMARY KEY (`k`) + ) + + $pre$tf_6 + CREATE TEMPORARY TABLE `tf_6` ( + `zz` INT, + `n` VARCHAR(255), + `o` VARCHAR(255), + PRIMARY KEY (`o`) + ) + + + $load + $load$tf_1 + INSERT INTO `tf_1` (`a`, `b`) + SELECT `a`, CAST(`b` AS CHAR) AS `b` + FROM ( + SELECT NULL AS `a`, NULL AS `b` + WHERE (0 = 1) + + UNION ALL + + VALUES + ROW(1, 'A'), + ROW(2, 'B'), + ROW(3, 'C'), + ROW(4, 'D'), + ROW(5, 'E'), + ROW(6, 'F'), + ROW(7, 'G'), + ROW(8, 'H'), + ROW(9, 'I'), + ROW(10, 'J') + ) `values_table` + + $load$tf_2 + INSERT INTO `tf_2` (`c`, `d`, `e`, `e1`) + SELECT + CAST(`c` AS CHAR) AS `c`, + `d`, + CAST(`e` AS CHAR) AS `e`, + `e1` + FROM ( + SELECT NULL AS `c`, NULL AS `d`, NULL AS `e`, NULL AS `e1` + WHERE (0 = 1) + + UNION ALL + + VALUES + ROW('cat', 7, 'F', 6), + ROW('dog', 6, 'E', 5), + ROW('elephant', 2, 'D', 4), + ROW('lion', 3, 'E', 5), + ROW('seal', 4, 'F', 6), + ROW('worm', 5, 'G', 7) + ) `values_table` + + $load$tf_3 + INSERT INTO `tf_3` (`f`, `f1`, `g`) + SELECT + CAST(`f` AS CHAR) AS `f`, + `f1`, + CAST(`g` AS CHAR) AS `g` + FROM ( + SELECT NULL AS `f`, NULL AS `f1`, NULL AS `g` + WHERE (0 = 1) + + UNION ALL + + VALUES + ROW('C', 2, 'one'), + ROW('C', 3, 'two'), + ROW('D', 4, 'three'), + ROW('E', 5, 'four'), + ROW('F', 6, 'five'), + ROW('G', 7, 'six'), + ROW('H', 7, 'seven'), + ROW('I', 7, 'eight'), + ROW('J', 10, 'nine'), + ROW('K', 11, 'ten') + ) `values_table` + + $load$tf_4 + INSERT INTO `tf_4` (`h`, `i`, `j`, `j1`) + SELECT + CAST(`h` AS CHAR) AS `h`, + CAST(`i` AS CHAR) AS `i`, + CAST(`j` AS CHAR) AS `j`, + `j1` + FROM ( + SELECT NULL AS `h`, NULL AS `i`, NULL AS `j`, NULL AS `j1` + WHERE (0 = 1) + + UNION ALL + + VALUES + ROW('a', 'three', 'C', 3), + ROW('b', 'four', 'D', 4), + ROW('c', 'five', 'E', 5), + ROW('d', 'six', 'F', 6), + ROW('e', 'seven', 'F', 6) + ) `values_table` + + $load$tf_5 + INSERT INTO `tf_5` (`ww`, `k`, `l`, `m`) + SELECT + `ww`, + `k`, + CAST(`l` AS CHAR) AS `l`, + CAST(`m` AS CHAR) AS `m` + FROM ( + SELECT NULL AS `ww`, NULL AS `k`, NULL AS `l`, NULL AS `m` + WHERE (0 = 1) + + UNION ALL + + VALUES + ROW(2, 1, 'b', 'house'), + ROW(2, 2, 'c', 'tree'), + ROW(2, 3, 'd', 'streetlamp'), + ROW(2, 4, 'e', 'streetlamp') + ) `values_table` + + $load$tf_6 + INSERT INTO `tf_6` (`zz`, `n`, `o`) + SELECT + `zz`, + CAST(`n` AS CHAR) AS `n`, + CAST(`o` AS CHAR) AS `o` + FROM ( + SELECT NULL AS `zz`, NULL AS `n`, NULL AS `o` + WHERE (0 = 1) + + UNION ALL + + VALUES + ROW(1, 'garden', 'i'), + ROW(1, 'hill', 'g'), + ROW(1, 'house', 'e'), + ROW(1, 'streetlamp', 'h'), + ROW(1, 'tree', 'f') + ) `values_table` + + + $post + $post$uk + $post$uk$tf_1 + ALTER TABLE `tf_1` ADD UNIQUE (`a`) + + $post$uk$tf_2 + ALTER TABLE `tf_2` ADD UNIQUE (`c`) + + $post$uk$tf_3 + ALTER TABLE `tf_3` ADD UNIQUE (`f`, `f1`) + ALTER TABLE `tf_3` ADD UNIQUE (`g`) + + $post$uk$tf_4 + ALTER TABLE `tf_4` ADD UNIQUE (`h`) + + $post$uk$tf_5 + ALTER TABLE `tf_5` ADD UNIQUE (`k`) + + $post$uk$tf_6 + ALTER TABLE `tf_6` ADD UNIQUE (`o`) + ALTER TABLE `tf_6` ADD UNIQUE (`n`) + + + $post$fk + named list() + + $post$indexes + $post$indexes$tf_2 + CREATE INDEX tf_2__d ON `tf_2` (`d`) + CREATE INDEX tf_2__e_e1 ON `tf_2` (`e`, `e1`) + + $post$indexes$tf_4 + CREATE INDEX tf_4__j_j1 ON `tf_4` (`j`, `j1`) + + $post$indexes$tf_5 + CREATE INDEX tf_5__l ON `tf_5` (`l`) + CREATE INDEX tf_5__m ON `tf_5` (`m`) + + + + +--- + + Code + dm(x = data.frame(a = strrep("x", 300))) %>% dm_sql(my_test_con()) + Output + $pre + $pre$x + CREATE TEMPORARY TABLE `x` ( + `a` VARCHAR(255) + ) + + + $load + $load$x + INSERT INTO `x` (`a`) + SELECT CAST(`a` AS CHAR) AS `a` + FROM ( + SELECT NULL AS `a` + WHERE (0 = 1) + + UNION ALL + + VALUES ROW('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') + ) `values_table` + + + $post + $post$uk + named list() + + $post$fk + named list() + + $post$indexes + named list() + + + +--- + + Code + dm(x = data.frame(a = strrep("x", 10000))) %>% dm_sql(my_test_con()) + Output + $p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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') + ) `values_table` + + + $post + $post$uk + named list() + + $post$fk + named list() + + $post$indexes + named list() + + + diff --git a/tests/testthat/_snaps/mysql/build_copy_queries.md b/tests/testthat/_snaps/mysql/build_copy_queries.md new file mode 100644 index 0000000000..d2630b5998 --- /dev/null +++ b/tests/testthat/_snaps/mysql/build_copy_queries.md @@ -0,0 +1,301 @@ +# build_copy_queries snapshot test for pixarfilms + + Code + pixar_dm %>% build_copy_queries(src_db, .) %>% as.list() + Output + $name + [1] "pixar_films" "academy" "box_office" "genres" + [5] "public_response" + + $remote_name + pixar_films academy box_office genres + "pixar_films" "academy" "box_office" "genres" + public_response + "public_response" + + $columns + $columns[[1]] + [1] "number" "film" "release_date" "run_time" "film_rating" + + $columns[[2]] + [1] "film" "award_type" "status" + + $columns[[3]] + [1] "film" "budget" "box_office_us_canada" + [4] "box_office_other" "box_office_worldwide" + + $columns[[4]] + [1] "film" "genre" + + $columns[[5]] + [1] "film" "rotten_tomatoes" "metacritic" "cinema_score" + [5] "critics_choice" + + + $sql_table + CREATE TEMPORARY TABLE `pixar_films` ( + `number` VARCHAR(255), + `film` VARCHAR(255), + `release_date` DATE, + `run_time` DOUBLE, + `film_rating` VARCHAR(255), + PRIMARY KEY (`film`) + ) + CREATE TEMPORARY TABLE `academy` ( + `film` VARCHAR(255), + `award_type` VARCHAR(255), + `status` VARCHAR(255), + PRIMARY KEY (`film`, `award_type`) + ) + CREATE TEMPORARY TABLE `box_office` ( + `film` VARCHAR(255), + `budget` DOUBLE, + `box_office_us_canada` DOUBLE, + `box_office_other` DOUBLE, + `box_office_worldwide` DOUBLE, + PRIMARY KEY (`film`) + ) + CREATE TEMPORARY TABLE `genres` ( + `film` VARCHAR(255), + `genre` VARCHAR(255), + PRIMARY KEY (`film`, `genre`) + ) + CREATE TEMPORARY TABLE `public_response` ( + `film` VARCHAR(255), + `rotten_tomatoes` DOUBLE, + `metacritic` DOUBLE, + `cinema_score` VARCHAR(255), + `critics_choice` DOUBLE, + PRIMARY KEY (`film`) + ) + + $sql_index + $sql_index[[1]] + NULL + + $sql_index[[2]] + NULL + + $sql_index[[3]] + NULL + + $sql_index[[4]] + NULL + + $sql_index[[5]] + NULL + + + $index_name + $index_name[[1]] + NULL + + $index_name[[2]] + NULL + + $index_name[[3]] + NULL + + $index_name[[4]] + NULL + + $index_name[[5]] + NULL + + + +# build_copy_queries snapshot test for dm_for_filter() + + Code + dm_for_filter() %>% build_copy_queries(src_db, .) %>% as.list() + Output + $name + [1] "tf_1" "tf_3" "tf_6" "tf_2" "tf_4" "tf_5" + + $remote_name + tf_1 tf_3 tf_6 tf_2 tf_4 tf_5 + "tf_1" "tf_3" "tf_6" "tf_2" "tf_4" "tf_5" + + $columns + $columns[[1]] + [1] "a" "b" + + $columns[[2]] + [1] "f" "f1" "g" + + $columns[[3]] + [1] "zz" "n" "o" + + $columns[[4]] + [1] "c" "d" "e" "e1" + + $columns[[5]] + [1] "h" "i" "j" "j1" + + $columns[[6]] + [1] "ww" "k" "l" "m" + + + $sql_table + CREATE TEMPORARY TABLE `tf_1` ( + `a` INT AUTO_INCREMENT, + `b` VARCHAR(255), + PRIMARY KEY (`a`) + ) + CREATE TEMPORARY TABLE `tf_3` ( + `f` VARCHAR(255), + `f1` INT, + `g` VARCHAR(255), + PRIMARY KEY (`f`, `f1`) + ) + CREATE TEMPORARY TABLE `tf_6` ( + `zz` INT, + `n` VARCHAR(255), + `o` VARCHAR(255), + PRIMARY KEY (`o`), + UNIQUE (`n`) + ) + CREATE TEMPORARY TABLE `tf_2` ( + `c` VARCHAR(255), + `d` INT, + `e` VARCHAR(255), + `e1` INT, + PRIMARY KEY (`c`) + ) + CREATE TEMPORARY TABLE `tf_4` ( + `h` VARCHAR(255), + `i` VARCHAR(255), + `j` VARCHAR(255), + `j1` INT, + PRIMARY KEY (`h`) + ) + CREATE TEMPORARY TABLE `tf_5` ( + `ww` INT, + `k` INT, + `l` VARCHAR(255), + `m` VARCHAR(255), + PRIMARY KEY (`k`) + ) + + $sql_index + $sql_index[[1]] + NULL + + $sql_index[[2]] + NULL + + $sql_index[[3]] + NULL + + $sql_index[[4]] + NULL + + $sql_index[[5]] + NULL + + $sql_index[[6]] + NULL + + + $index_name + $index_name[[1]] + NULL + + $index_name[[2]] + NULL + + $index_name[[3]] + NULL + + $index_name[[4]] + NULL + + $index_name[[5]] + NULL + + $index_name[[6]] + NULL + + + +# build_copy_queries avoids duplicate indexes + + Code + as.list(queries) + Output + $name + [1] "parent1" "parent2" "child" "child__a" + + $remote_name + $remote_name$parent1 + table = parent1 + + $remote_name$parent2 + table = parent2 + + $remote_name$child + table = child + + $remote_name$child__a + table = child__a + + + $columns + $columns[[1]] + [1] "key" + + $columns[[2]] + [1] "a__key" + + $columns[[3]] + [1] "a__key" + + $columns[[4]] + [1] "key" + + + $sql_table + CREATE TEMPORARY TABLE `parent1` ( + `key` DOUBLE, + PRIMARY KEY (`key`) + ) + CREATE TEMPORARY TABLE `parent2` ( + `a__key` DOUBLE, + PRIMARY KEY (`a__key`) + ) + CREATE TEMPORARY TABLE `child` ( + `a__key` DOUBLE + ) + CREATE TEMPORARY TABLE `child__a` ( + `key` DOUBLE + ) + + $sql_index + $sql_index[[1]] + NULL + + $sql_index[[2]] + NULL + + $sql_index[[3]] + NULL + + $sql_index[[4]] + NULL + + + $index_name + $index_name[[1]] + NULL + + $index_name[[2]] + NULL + + $index_name[[3]] + NULL + + $index_name[[4]] + NULL + + + diff --git a/tests/testthat/_snaps/mysql/flatten.md b/tests/testthat/_snaps/mysql/flatten.md new file mode 100644 index 0000000000..27854c6205 --- /dev/null +++ b/tests/testthat/_snaps/mysql/flatten.md @@ -0,0 +1,20 @@ +# `dm_flatten_to_tbl()` does the right things for 'inner_join()' + + Code + out + Output + fact dim_1_key_1 dim_1_key_2 dim_2_key dim_3_key dim_4_key something.fact + + 1 acorn 14 N c X 7 1 + 2 blubber 13 M d W 8 2 + 3 cindere~ 12 L e V 9 3 + 4 depth 11 K f U 10 4 + 5 elysium 10 J g T 11 5 + 6 fantasy 9 I h S 12 6 + 7 gorgeous 8 H i R 13 7 + 8 halo 7 G j Q 14 8 + 9 ill-adv~ 6 F k P 15 9 + 10 jitter 5 E l O 16 10 + # i 4 more variables: something.dim_1 , something.dim_2 , + # something.dim_3 , something.dim_4 + diff --git a/tests/testthat/helper-config-db.R b/tests/testthat/helper-config-db.R index b414656b21..6d3b08de6b 100644 --- a/tests/testthat/helper-config-db.R +++ b/tests/testthat/helper-config-db.R @@ -45,6 +45,23 @@ test_src_maria <- function(root = FALSE) { dbplyr::src_dbi(con, auto_disconnect = TRUE) } +test_src_mysql <- function(root = FALSE) { + if (Sys.getenv("DM_TEST_DOCKER_HOST") != "") { + con <- DBI::dbConnect( + RMariaDB::MariaDB(), + host = Sys.getenv("DM_TEST_DOCKER_HOST"), + username = if (root) "root" else "compose", + password = "YourStrong!Passw0rd", + dbname = "test", + port = 3307, + mysql = TRUE + ) + } else { + con <- DBI::dbConnect(RMariaDB::MariaDB(), dbname = "test", mysql = TRUE) + } + dbplyr::src_dbi(con, auto_disconnect = TRUE) +} + test_src_mssql <- function(database = TRUE) { if (Sys.getenv("DM_TEST_DOCKER_HOST") != "") { con <- DBI::dbConnect( diff --git a/tests/testthat/helper-sync.R b/tests/testthat/helper-sync.R index ac00e0c737..b8def43e5d 100644 --- a/tests/testthat/helper-sync.R +++ b/tests/testthat/helper-sync.R @@ -19,6 +19,7 @@ local({ sources <- c( "duckdb", "maria", + "mysql", "mssql", "postgres", "sqlite", diff --git a/tests/testthat/test-duckdb.R b/tests/testthat/test-duckdb.R index 48dee7e9bc..485977e612 100644 --- a/tests/testthat/test-duckdb.R +++ b/tests/testthat/test-duckdb.R @@ -8,9 +8,6 @@ test_that("dm_sql()", { # Need skip in every test block, unfortunately skip_if_src_not("duckdb") - # https://github.com/tidyverse/dbplyr/pull/1190 - skip_if(is(my_test_con(), "MySQLConnection")) - expect_snapshot({ dm_for_filter_df() %>% dm_sql(my_test_con()) diff --git a/tests/testthat/test-maria.R b/tests/testthat/test-maria.R index 13db37d47f..ad088dd593 100644 --- a/tests/testthat/test-maria.R +++ b/tests/testthat/test-maria.R @@ -8,9 +8,6 @@ test_that("dm_sql()", { # Need skip in every test block, unfortunately skip_if_src_not("maria") - # https://github.com/tidyverse/dbplyr/pull/1190 - skip_if(is(my_test_con(), "MySQLConnection")) - expect_snapshot({ dm_for_filter_df() %>% dm_sql(my_test_con()) diff --git a/tests/testthat/test-mssql.R b/tests/testthat/test-mssql.R index fe73fd2e0b..324d0f384c 100644 --- a/tests/testthat/test-mssql.R +++ b/tests/testthat/test-mssql.R @@ -8,9 +8,6 @@ test_that("dm_sql()", { # Need skip in every test block, unfortunately skip_if_src_not("mssql") - # https://github.com/tidyverse/dbplyr/pull/1190 - skip_if(is(my_test_con(), "MySQLConnection")) - expect_snapshot({ dm_for_filter_df() %>% dm_sql(my_test_con()) diff --git a/tests/testthat/test-mysql.R b/tests/testthat/test-mysql.R new file mode 100644 index 0000000000..f0afa8a41c --- /dev/null +++ b/tests/testthat/test-mysql.R @@ -0,0 +1,25 @@ +test_that("dummy", { + expect_snapshot({ + "dummy" + }) +}) + +test_that("dm_sql()", { + # Need skip in every test block, unfortunately + skip_if_src_not("mysql") + + expect_snapshot({ + dm_for_filter_df() %>% + dm_sql(my_test_con()) + }) + + expect_snapshot({ + dm(x = data.frame(a = strrep("x", 300))) %>% + dm_sql(my_test_con()) + }) + + expect_snapshot({ + dm(x = data.frame(a = strrep("x", 10000))) %>% + dm_sql(my_test_con()) + }) +}) diff --git a/tests/testthat/test-postgres.R b/tests/testthat/test-postgres.R index a324f3c83d..4912e935db 100644 --- a/tests/testthat/test-postgres.R +++ b/tests/testthat/test-postgres.R @@ -8,9 +8,6 @@ test_that("dm_sql()", { # Need skip in every test block, unfortunately skip_if_src_not("postgres") - # https://github.com/tidyverse/dbplyr/pull/1190 - skip_if(is(my_test_con(), "MySQLConnection")) - expect_snapshot({ dm_for_filter_df() %>% dm_sql(my_test_con()) diff --git a/tests/testthat/test-sqlite.R b/tests/testthat/test-sqlite.R index 41362415ee..3db575dc2a 100644 --- a/tests/testthat/test-sqlite.R +++ b/tests/testthat/test-sqlite.R @@ -8,9 +8,6 @@ test_that("dm_sql()", { # Need skip in every test block, unfortunately skip_if_src_not("sqlite") - # https://github.com/tidyverse/dbplyr/pull/1190 - skip_if(is(my_test_con(), "MySQLConnection")) - expect_snapshot({ dm_for_filter_df() %>% dm_sql(my_test_con())