diff --git a/R/list_tables.R b/R/list_tables.R index 854a2eeda4343a78b82978e9930bb5fb7aad51a0..33559df95663208a3316eddce08a5adc7c29726b 100644 --- a/R/list_tables.R +++ b/R/list_tables.R @@ -7,6 +7,7 @@ #' @param ... eventuels autres arguments de la fonction d'ouverture de connexion `connect_to_db` #' @return Un vecteur de caractères avec les tables présentes sur le schéma schema du connecteur con. #' @importFrom attempt stop_if_all message_if_none stop_if stop_if_not +#' @importFrom dplyr arrange select #' @importFrom DBI dbGetQuery dbDisconnect #' @importFrom glue glue #' @export @@ -39,8 +40,9 @@ list_tables <- function(con = NULL, schema = NULL, db = NULL, user = NULL, ...) if(con_a_creer_fermer) { DBI::dbDisconnect(connexion) } - - return(all_tables$table_name) + res<- all_tables %>% arrange(table_name) + res <- res$table_name + return(res) } diff --git a/tests/testthat/_snaps/4-post_data.md b/tests/testthat/_snaps/4-post_data.md new file mode 100644 index 0000000000000000000000000000000000000000..c1cd496cdde44c051d2ea836cb08913142ae62c9 --- /dev/null +++ b/tests/testthat/_snaps/4-post_data.md @@ -0,0 +1,14 @@ +# poster_data works + + Code + list_tables(schema = schem, db = "test_datalibaba", user = "test") + Output + character(0) + +--- + + Code + list_tables(schema = schem, con = con) + Output + character(0) + diff --git a/tests/testthat/_snaps/5-get_data.md b/tests/testthat/_snaps/5-get_data.md index f452baf48b2b57a444e3d307edd0cdf8fd217491..78ea15ede8875097d7400c9af0880de98c167cfe 100644 --- a/tests/testthat/_snaps/5-get_data.md +++ b/tests/testthat/_snaps/5-get_data.md @@ -10,15 +10,19 @@ 3 3 4.7 3.2 1.3 0.2 setosa 4 4 4.6 3.1 1.5 0.2 setosa todate - 1 2025-02-27 08:19:51 - 2 2025-02-27 08:19:51 - 3 2025-02-27 08:19:51 - 4 2025-02-27 08:19:51 + 1 2025-02-27 14:29:32 + 2 2025-02-27 14:29:32 + 3 2025-02-27 14:29:32 + 4 2025-02-27 14:29:32 --- Code importer_data(table = "nc", schema = "public", db = "test_datalibaba", user = "test") + Condition + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"id_row__"` instead of `.data$id_row__` Output Simple feature collection with 100 features and 14 fields Geometry type: MULTIPOLYGON @@ -54,6 +58,10 @@ Code importer_data(table = "nc", schema = "public", db = "test_datalibaba", user = "test", limit = 4) + Condition + Warning: + Use of .data in tidyselect expressions was deprecated in tidyselect 1.2.0. + i Please use `"id_row__"` instead of `.data$id_row__` Output Simple feature collection with 4 features and 14 fields Geometry type: MULTIPOLYGON @@ -93,15 +101,6 @@ 3 208 3616 6 260 MULTIPOLYGON (((-80.45634 3... 4 123 830 2 145 MULTIPOLYGON (((-76.00897 3... ---- - - Code - list_tables(schema = "public", db = "test_datalibaba", user = "test") - Output - [1] "zz_r_df_def" "geography_columns" "geometry_columns" - [4] "spatial_ref_sys" "retest_iris" "test_iris" - [7] "test_nc_noid" "nc" - # get_data works Code @@ -259,156 +258,156 @@ 149 149 6.2 3.4 5.4 2.3 virginica 150 150 5.9 3.0 5.1 1.8 virginica todate r_row_names__ - 1 2025-02-27 09:19:51 1 - 2 2025-02-27 09:19:51 2 - 3 2025-02-27 09:19:51 3 - 4 2025-02-27 09:19:51 4 - 5 2025-02-27 09:19:51 5 - 6 2025-02-27 09:19:51 6 - 7 2025-02-27 09:19:51 7 - 8 2025-02-27 09:19:51 8 - 9 2025-02-27 09:19:51 9 - 10 2025-02-27 09:19:51 10 - 11 2025-02-27 09:19:51 11 - 12 2025-02-27 09:19:51 12 - 13 2025-02-27 09:19:51 13 - 14 2025-02-27 09:19:51 14 - 15 2025-02-27 09:19:51 15 - 16 2025-02-27 09:19:51 16 - 17 2025-02-27 09:19:51 17 - 18 2025-02-27 09:19:51 18 - 19 2025-02-27 09:19:51 19 - 20 2025-02-27 09:19:51 20 - 21 2025-02-27 09:19:51 21 - 22 2025-02-27 09:19:51 22 - 23 2025-02-27 09:19:51 23 - 24 2025-02-27 09:19:51 24 - 25 2025-02-27 09:19:51 25 - 26 2025-02-27 09:19:51 26 - 27 2025-02-27 09:19:51 27 - 28 2025-02-27 09:19:51 28 - 29 2025-02-27 09:19:51 29 - 30 2025-02-27 09:19:51 30 - 31 2025-02-27 09:19:51 31 - 32 2025-02-27 09:19:51 32 - 33 2025-02-27 09:19:51 33 - 34 2025-02-27 09:19:51 34 - 35 2025-02-27 09:19:51 35 - 36 2025-02-27 09:19:51 36 - 37 2025-02-27 09:19:51 37 - 38 2025-02-27 09:19:51 38 - 39 2025-02-27 09:19:51 39 - 40 2025-02-27 09:19:51 40 - 41 2025-02-27 09:19:51 41 - 42 2025-02-27 09:19:51 42 - 43 2025-02-27 09:19:51 43 - 44 2025-02-27 09:19:51 44 - 45 2025-02-27 09:19:51 45 - 46 2025-02-27 09:19:51 46 - 47 2025-02-27 09:19:51 47 - 48 2025-02-27 09:19:51 48 - 49 2025-02-27 09:19:51 49 - 50 2025-02-27 09:19:51 50 - 51 2025-02-27 09:19:51 51 - 52 2025-02-27 09:19:51 52 - 53 2025-02-27 09:19:51 53 - 54 2025-02-27 09:19:51 54 - 55 2025-02-27 09:19:51 55 - 56 2025-02-27 09:19:51 56 - 57 2025-02-27 09:19:51 57 - 58 2025-02-27 09:19:51 58 - 59 2025-02-27 09:19:51 59 - 60 2025-02-27 09:19:51 60 - 61 2025-02-27 09:19:51 61 - 62 2025-02-27 09:19:51 62 - 63 2025-02-27 09:19:51 63 - 64 2025-02-27 09:19:51 64 - 65 2025-02-27 09:19:51 65 - 66 2025-02-27 09:19:51 66 - 67 2025-02-27 09:19:51 67 - 68 2025-02-27 09:19:51 68 - 69 2025-02-27 09:19:51 69 - 70 2025-02-27 09:19:51 70 - 71 2025-02-27 09:19:51 71 - 72 2025-02-27 09:19:51 72 - 73 2025-02-27 09:19:51 73 - 74 2025-02-27 09:19:51 74 - 75 2025-02-27 09:19:51 75 - 76 2025-02-27 09:19:51 76 - 77 2025-02-27 09:19:51 77 - 78 2025-02-27 09:19:51 78 - 79 2025-02-27 09:19:51 79 - 80 2025-02-27 09:19:51 80 - 81 2025-02-27 09:19:51 81 - 82 2025-02-27 09:19:51 82 - 83 2025-02-27 09:19:51 83 - 84 2025-02-27 09:19:51 84 - 85 2025-02-27 09:19:51 85 - 86 2025-02-27 09:19:51 86 - 87 2025-02-27 09:19:51 87 - 88 2025-02-27 09:19:51 88 - 89 2025-02-27 09:19:51 89 - 90 2025-02-27 09:19:51 90 - 91 2025-02-27 09:19:51 91 - 92 2025-02-27 09:19:51 92 - 93 2025-02-27 09:19:51 93 - 94 2025-02-27 09:19:51 94 - 95 2025-02-27 09:19:51 95 - 96 2025-02-27 09:19:51 96 - 97 2025-02-27 09:19:51 97 - 98 2025-02-27 09:19:51 98 - 99 2025-02-27 09:19:51 99 - 100 2025-02-27 09:19:51 100 - 101 2025-02-27 09:19:51 101 - 102 2025-02-27 09:19:51 102 - 103 2025-02-27 09:19:51 103 - 104 2025-02-27 09:19:51 104 - 105 2025-02-27 09:19:51 105 - 106 2025-02-27 09:19:51 106 - 107 2025-02-27 09:19:51 107 - 108 2025-02-27 09:19:51 108 - 109 2025-02-27 09:19:51 109 - 110 2025-02-27 09:19:51 110 - 111 2025-02-27 09:19:51 111 - 112 2025-02-27 09:19:51 112 - 113 2025-02-27 09:19:51 113 - 114 2025-02-27 09:19:51 114 - 115 2025-02-27 09:19:51 115 - 116 2025-02-27 09:19:51 116 - 117 2025-02-27 09:19:51 117 - 118 2025-02-27 09:19:51 118 - 119 2025-02-27 09:19:51 119 - 120 2025-02-27 09:19:51 120 - 121 2025-02-27 09:19:51 121 - 122 2025-02-27 09:19:51 122 - 123 2025-02-27 09:19:51 123 - 124 2025-02-27 09:19:51 124 - 125 2025-02-27 09:19:51 125 - 126 2025-02-27 09:19:51 126 - 127 2025-02-27 09:19:51 127 - 128 2025-02-27 09:19:51 128 - 129 2025-02-27 09:19:51 129 - 130 2025-02-27 09:19:51 130 - 131 2025-02-27 09:19:51 131 - 132 2025-02-27 09:19:51 132 - 133 2025-02-27 09:19:51 133 - 134 2025-02-27 09:19:51 134 - 135 2025-02-27 09:19:51 135 - 136 2025-02-27 09:19:51 136 - 137 2025-02-27 09:19:51 137 - 138 2025-02-27 09:19:51 138 - 139 2025-02-27 09:19:51 139 - 140 2025-02-27 09:19:51 140 - 141 2025-02-27 09:19:51 141 - 142 2025-02-27 09:19:51 142 - 143 2025-02-27 09:19:51 143 - 144 2025-02-27 09:19:51 144 - 145 2025-02-27 09:19:51 145 - 146 2025-02-27 09:19:51 146 - 147 2025-02-27 09:19:51 147 - 148 2025-02-27 09:19:51 148 - 149 2025-02-27 09:19:51 149 - 150 2025-02-27 09:19:51 150 + 1 2025-02-27 15:29:32 1 + 2 2025-02-27 15:29:32 2 + 3 2025-02-27 15:29:32 3 + 4 2025-02-27 15:29:32 4 + 5 2025-02-27 15:29:32 5 + 6 2025-02-27 15:29:32 6 + 7 2025-02-27 15:29:32 7 + 8 2025-02-27 15:29:32 8 + 9 2025-02-27 15:29:32 9 + 10 2025-02-27 15:29:32 10 + 11 2025-02-27 15:29:32 11 + 12 2025-02-27 15:29:32 12 + 13 2025-02-27 15:29:32 13 + 14 2025-02-27 15:29:32 14 + 15 2025-02-27 15:29:32 15 + 16 2025-02-27 15:29:32 16 + 17 2025-02-27 15:29:32 17 + 18 2025-02-27 15:29:32 18 + 19 2025-02-27 15:29:32 19 + 20 2025-02-27 15:29:32 20 + 21 2025-02-27 15:29:32 21 + 22 2025-02-27 15:29:32 22 + 23 2025-02-27 15:29:32 23 + 24 2025-02-27 15:29:32 24 + 25 2025-02-27 15:29:32 25 + 26 2025-02-27 15:29:32 26 + 27 2025-02-27 15:29:32 27 + 28 2025-02-27 15:29:32 28 + 29 2025-02-27 15:29:32 29 + 30 2025-02-27 15:29:32 30 + 31 2025-02-27 15:29:32 31 + 32 2025-02-27 15:29:32 32 + 33 2025-02-27 15:29:32 33 + 34 2025-02-27 15:29:32 34 + 35 2025-02-27 15:29:32 35 + 36 2025-02-27 15:29:32 36 + 37 2025-02-27 15:29:32 37 + 38 2025-02-27 15:29:32 38 + 39 2025-02-27 15:29:32 39 + 40 2025-02-27 15:29:32 40 + 41 2025-02-27 15:29:32 41 + 42 2025-02-27 15:29:32 42 + 43 2025-02-27 15:29:32 43 + 44 2025-02-27 15:29:32 44 + 45 2025-02-27 15:29:32 45 + 46 2025-02-27 15:29:32 46 + 47 2025-02-27 15:29:32 47 + 48 2025-02-27 15:29:32 48 + 49 2025-02-27 15:29:32 49 + 50 2025-02-27 15:29:32 50 + 51 2025-02-27 15:29:32 51 + 52 2025-02-27 15:29:32 52 + 53 2025-02-27 15:29:32 53 + 54 2025-02-27 15:29:32 54 + 55 2025-02-27 15:29:32 55 + 56 2025-02-27 15:29:32 56 + 57 2025-02-27 15:29:32 57 + 58 2025-02-27 15:29:32 58 + 59 2025-02-27 15:29:32 59 + 60 2025-02-27 15:29:32 60 + 61 2025-02-27 15:29:32 61 + 62 2025-02-27 15:29:32 62 + 63 2025-02-27 15:29:32 63 + 64 2025-02-27 15:29:32 64 + 65 2025-02-27 15:29:32 65 + 66 2025-02-27 15:29:32 66 + 67 2025-02-27 15:29:32 67 + 68 2025-02-27 15:29:32 68 + 69 2025-02-27 15:29:32 69 + 70 2025-02-27 15:29:32 70 + 71 2025-02-27 15:29:32 71 + 72 2025-02-27 15:29:32 72 + 73 2025-02-27 15:29:32 73 + 74 2025-02-27 15:29:32 74 + 75 2025-02-27 15:29:32 75 + 76 2025-02-27 15:29:32 76 + 77 2025-02-27 15:29:32 77 + 78 2025-02-27 15:29:32 78 + 79 2025-02-27 15:29:32 79 + 80 2025-02-27 15:29:32 80 + 81 2025-02-27 15:29:32 81 + 82 2025-02-27 15:29:32 82 + 83 2025-02-27 15:29:32 83 + 84 2025-02-27 15:29:32 84 + 85 2025-02-27 15:29:32 85 + 86 2025-02-27 15:29:32 86 + 87 2025-02-27 15:29:32 87 + 88 2025-02-27 15:29:32 88 + 89 2025-02-27 15:29:32 89 + 90 2025-02-27 15:29:32 90 + 91 2025-02-27 15:29:32 91 + 92 2025-02-27 15:29:32 92 + 93 2025-02-27 15:29:32 93 + 94 2025-02-27 15:29:32 94 + 95 2025-02-27 15:29:32 95 + 96 2025-02-27 15:29:32 96 + 97 2025-02-27 15:29:32 97 + 98 2025-02-27 15:29:32 98 + 99 2025-02-27 15:29:32 99 + 100 2025-02-27 15:29:32 100 + 101 2025-02-27 15:29:32 101 + 102 2025-02-27 15:29:32 102 + 103 2025-02-27 15:29:32 103 + 104 2025-02-27 15:29:32 104 + 105 2025-02-27 15:29:32 105 + 106 2025-02-27 15:29:32 106 + 107 2025-02-27 15:29:32 107 + 108 2025-02-27 15:29:32 108 + 109 2025-02-27 15:29:32 109 + 110 2025-02-27 15:29:32 110 + 111 2025-02-27 15:29:32 111 + 112 2025-02-27 15:29:32 112 + 113 2025-02-27 15:29:32 113 + 114 2025-02-27 15:29:32 114 + 115 2025-02-27 15:29:32 115 + 116 2025-02-27 15:29:32 116 + 117 2025-02-27 15:29:32 117 + 118 2025-02-27 15:29:32 118 + 119 2025-02-27 15:29:32 119 + 120 2025-02-27 15:29:32 120 + 121 2025-02-27 15:29:32 121 + 122 2025-02-27 15:29:32 122 + 123 2025-02-27 15:29:32 123 + 124 2025-02-27 15:29:32 124 + 125 2025-02-27 15:29:32 125 + 126 2025-02-27 15:29:32 126 + 127 2025-02-27 15:29:32 127 + 128 2025-02-27 15:29:32 128 + 129 2025-02-27 15:29:32 129 + 130 2025-02-27 15:29:32 130 + 131 2025-02-27 15:29:32 131 + 132 2025-02-27 15:29:32 132 + 133 2025-02-27 15:29:32 133 + 134 2025-02-27 15:29:32 134 + 135 2025-02-27 15:29:32 135 + 136 2025-02-27 15:29:32 136 + 137 2025-02-27 15:29:32 137 + 138 2025-02-27 15:29:32 138 + 139 2025-02-27 15:29:32 139 + 140 2025-02-27 15:29:32 140 + 141 2025-02-27 15:29:32 141 + 142 2025-02-27 15:29:32 142 + 143 2025-02-27 15:29:32 143 + 144 2025-02-27 15:29:32 144 + 145 2025-02-27 15:29:32 145 + 146 2025-02-27 15:29:32 146 + 147 2025-02-27 15:29:32 147 + 148 2025-02-27 15:29:32 148 + 149 2025-02-27 15:29:32 149 + 150 2025-02-27 15:29:32 150 # get_data_dbi works @@ -567,154 +566,154 @@ 149 149 6.2 3.4 5.4 2.3 virginica 150 150 5.9 3.0 5.1 1.8 virginica todate r_row_names__ - 1 2025-02-27 08:19:51 1 - 2 2025-02-27 08:19:51 2 - 3 2025-02-27 08:19:51 3 - 4 2025-02-27 08:19:51 4 - 5 2025-02-27 08:19:51 5 - 6 2025-02-27 08:19:51 6 - 7 2025-02-27 08:19:51 7 - 8 2025-02-27 08:19:51 8 - 9 2025-02-27 08:19:51 9 - 10 2025-02-27 08:19:51 10 - 11 2025-02-27 08:19:51 11 - 12 2025-02-27 08:19:51 12 - 13 2025-02-27 08:19:51 13 - 14 2025-02-27 08:19:51 14 - 15 2025-02-27 08:19:51 15 - 16 2025-02-27 08:19:51 16 - 17 2025-02-27 08:19:51 17 - 18 2025-02-27 08:19:51 18 - 19 2025-02-27 08:19:51 19 - 20 2025-02-27 08:19:51 20 - 21 2025-02-27 08:19:51 21 - 22 2025-02-27 08:19:51 22 - 23 2025-02-27 08:19:51 23 - 24 2025-02-27 08:19:51 24 - 25 2025-02-27 08:19:51 25 - 26 2025-02-27 08:19:51 26 - 27 2025-02-27 08:19:51 27 - 28 2025-02-27 08:19:51 28 - 29 2025-02-27 08:19:51 29 - 30 2025-02-27 08:19:51 30 - 31 2025-02-27 08:19:51 31 - 32 2025-02-27 08:19:51 32 - 33 2025-02-27 08:19:51 33 - 34 2025-02-27 08:19:51 34 - 35 2025-02-27 08:19:51 35 - 36 2025-02-27 08:19:51 36 - 37 2025-02-27 08:19:51 37 - 38 2025-02-27 08:19:51 38 - 39 2025-02-27 08:19:51 39 - 40 2025-02-27 08:19:51 40 - 41 2025-02-27 08:19:51 41 - 42 2025-02-27 08:19:51 42 - 43 2025-02-27 08:19:51 43 - 44 2025-02-27 08:19:51 44 - 45 2025-02-27 08:19:51 45 - 46 2025-02-27 08:19:51 46 - 47 2025-02-27 08:19:51 47 - 48 2025-02-27 08:19:51 48 - 49 2025-02-27 08:19:51 49 - 50 2025-02-27 08:19:51 50 - 51 2025-02-27 08:19:51 51 - 52 2025-02-27 08:19:51 52 - 53 2025-02-27 08:19:51 53 - 54 2025-02-27 08:19:51 54 - 55 2025-02-27 08:19:51 55 - 56 2025-02-27 08:19:51 56 - 57 2025-02-27 08:19:51 57 - 58 2025-02-27 08:19:51 58 - 59 2025-02-27 08:19:51 59 - 60 2025-02-27 08:19:51 60 - 61 2025-02-27 08:19:51 61 - 62 2025-02-27 08:19:51 62 - 63 2025-02-27 08:19:51 63 - 64 2025-02-27 08:19:51 64 - 65 2025-02-27 08:19:51 65 - 66 2025-02-27 08:19:51 66 - 67 2025-02-27 08:19:51 67 - 68 2025-02-27 08:19:51 68 - 69 2025-02-27 08:19:51 69 - 70 2025-02-27 08:19:51 70 - 71 2025-02-27 08:19:51 71 - 72 2025-02-27 08:19:51 72 - 73 2025-02-27 08:19:51 73 - 74 2025-02-27 08:19:51 74 - 75 2025-02-27 08:19:51 75 - 76 2025-02-27 08:19:51 76 - 77 2025-02-27 08:19:51 77 - 78 2025-02-27 08:19:51 78 - 79 2025-02-27 08:19:51 79 - 80 2025-02-27 08:19:51 80 - 81 2025-02-27 08:19:51 81 - 82 2025-02-27 08:19:51 82 - 83 2025-02-27 08:19:51 83 - 84 2025-02-27 08:19:51 84 - 85 2025-02-27 08:19:51 85 - 86 2025-02-27 08:19:51 86 - 87 2025-02-27 08:19:51 87 - 88 2025-02-27 08:19:51 88 - 89 2025-02-27 08:19:51 89 - 90 2025-02-27 08:19:51 90 - 91 2025-02-27 08:19:51 91 - 92 2025-02-27 08:19:51 92 - 93 2025-02-27 08:19:51 93 - 94 2025-02-27 08:19:51 94 - 95 2025-02-27 08:19:51 95 - 96 2025-02-27 08:19:51 96 - 97 2025-02-27 08:19:51 97 - 98 2025-02-27 08:19:51 98 - 99 2025-02-27 08:19:51 99 - 100 2025-02-27 08:19:51 100 - 101 2025-02-27 08:19:51 101 - 102 2025-02-27 08:19:51 102 - 103 2025-02-27 08:19:51 103 - 104 2025-02-27 08:19:51 104 - 105 2025-02-27 08:19:51 105 - 106 2025-02-27 08:19:51 106 - 107 2025-02-27 08:19:51 107 - 108 2025-02-27 08:19:51 108 - 109 2025-02-27 08:19:51 109 - 110 2025-02-27 08:19:51 110 - 111 2025-02-27 08:19:51 111 - 112 2025-02-27 08:19:51 112 - 113 2025-02-27 08:19:51 113 - 114 2025-02-27 08:19:51 114 - 115 2025-02-27 08:19:51 115 - 116 2025-02-27 08:19:51 116 - 117 2025-02-27 08:19:51 117 - 118 2025-02-27 08:19:51 118 - 119 2025-02-27 08:19:51 119 - 120 2025-02-27 08:19:51 120 - 121 2025-02-27 08:19:51 121 - 122 2025-02-27 08:19:51 122 - 123 2025-02-27 08:19:51 123 - 124 2025-02-27 08:19:51 124 - 125 2025-02-27 08:19:51 125 - 126 2025-02-27 08:19:51 126 - 127 2025-02-27 08:19:51 127 - 128 2025-02-27 08:19:51 128 - 129 2025-02-27 08:19:51 129 - 130 2025-02-27 08:19:51 130 - 131 2025-02-27 08:19:51 131 - 132 2025-02-27 08:19:51 132 - 133 2025-02-27 08:19:51 133 - 134 2025-02-27 08:19:51 134 - 135 2025-02-27 08:19:51 135 - 136 2025-02-27 08:19:51 136 - 137 2025-02-27 08:19:51 137 - 138 2025-02-27 08:19:51 138 - 139 2025-02-27 08:19:51 139 - 140 2025-02-27 08:19:51 140 - 141 2025-02-27 08:19:51 141 - 142 2025-02-27 08:19:51 142 - 143 2025-02-27 08:19:51 143 - 144 2025-02-27 08:19:51 144 - 145 2025-02-27 08:19:51 145 - 146 2025-02-27 08:19:51 146 - 147 2025-02-27 08:19:51 147 - 148 2025-02-27 08:19:51 148 - 149 2025-02-27 08:19:51 149 - 150 2025-02-27 08:19:51 150 + 1 2025-02-27 14:29:32 1 + 2 2025-02-27 14:29:32 2 + 3 2025-02-27 14:29:32 3 + 4 2025-02-27 14:29:32 4 + 5 2025-02-27 14:29:32 5 + 6 2025-02-27 14:29:32 6 + 7 2025-02-27 14:29:32 7 + 8 2025-02-27 14:29:32 8 + 9 2025-02-27 14:29:32 9 + 10 2025-02-27 14:29:32 10 + 11 2025-02-27 14:29:32 11 + 12 2025-02-27 14:29:32 12 + 13 2025-02-27 14:29:32 13 + 14 2025-02-27 14:29:32 14 + 15 2025-02-27 14:29:32 15 + 16 2025-02-27 14:29:32 16 + 17 2025-02-27 14:29:32 17 + 18 2025-02-27 14:29:32 18 + 19 2025-02-27 14:29:32 19 + 20 2025-02-27 14:29:32 20 + 21 2025-02-27 14:29:32 21 + 22 2025-02-27 14:29:32 22 + 23 2025-02-27 14:29:32 23 + 24 2025-02-27 14:29:32 24 + 25 2025-02-27 14:29:32 25 + 26 2025-02-27 14:29:32 26 + 27 2025-02-27 14:29:32 27 + 28 2025-02-27 14:29:32 28 + 29 2025-02-27 14:29:32 29 + 30 2025-02-27 14:29:32 30 + 31 2025-02-27 14:29:32 31 + 32 2025-02-27 14:29:32 32 + 33 2025-02-27 14:29:32 33 + 34 2025-02-27 14:29:32 34 + 35 2025-02-27 14:29:32 35 + 36 2025-02-27 14:29:32 36 + 37 2025-02-27 14:29:32 37 + 38 2025-02-27 14:29:32 38 + 39 2025-02-27 14:29:32 39 + 40 2025-02-27 14:29:32 40 + 41 2025-02-27 14:29:32 41 + 42 2025-02-27 14:29:32 42 + 43 2025-02-27 14:29:32 43 + 44 2025-02-27 14:29:32 44 + 45 2025-02-27 14:29:32 45 + 46 2025-02-27 14:29:32 46 + 47 2025-02-27 14:29:32 47 + 48 2025-02-27 14:29:32 48 + 49 2025-02-27 14:29:32 49 + 50 2025-02-27 14:29:32 50 + 51 2025-02-27 14:29:32 51 + 52 2025-02-27 14:29:32 52 + 53 2025-02-27 14:29:32 53 + 54 2025-02-27 14:29:32 54 + 55 2025-02-27 14:29:32 55 + 56 2025-02-27 14:29:32 56 + 57 2025-02-27 14:29:32 57 + 58 2025-02-27 14:29:32 58 + 59 2025-02-27 14:29:32 59 + 60 2025-02-27 14:29:32 60 + 61 2025-02-27 14:29:32 61 + 62 2025-02-27 14:29:32 62 + 63 2025-02-27 14:29:32 63 + 64 2025-02-27 14:29:32 64 + 65 2025-02-27 14:29:32 65 + 66 2025-02-27 14:29:32 66 + 67 2025-02-27 14:29:32 67 + 68 2025-02-27 14:29:32 68 + 69 2025-02-27 14:29:32 69 + 70 2025-02-27 14:29:32 70 + 71 2025-02-27 14:29:32 71 + 72 2025-02-27 14:29:32 72 + 73 2025-02-27 14:29:32 73 + 74 2025-02-27 14:29:32 74 + 75 2025-02-27 14:29:32 75 + 76 2025-02-27 14:29:32 76 + 77 2025-02-27 14:29:32 77 + 78 2025-02-27 14:29:32 78 + 79 2025-02-27 14:29:32 79 + 80 2025-02-27 14:29:32 80 + 81 2025-02-27 14:29:32 81 + 82 2025-02-27 14:29:32 82 + 83 2025-02-27 14:29:32 83 + 84 2025-02-27 14:29:32 84 + 85 2025-02-27 14:29:32 85 + 86 2025-02-27 14:29:32 86 + 87 2025-02-27 14:29:32 87 + 88 2025-02-27 14:29:32 88 + 89 2025-02-27 14:29:32 89 + 90 2025-02-27 14:29:32 90 + 91 2025-02-27 14:29:32 91 + 92 2025-02-27 14:29:32 92 + 93 2025-02-27 14:29:32 93 + 94 2025-02-27 14:29:32 94 + 95 2025-02-27 14:29:32 95 + 96 2025-02-27 14:29:32 96 + 97 2025-02-27 14:29:32 97 + 98 2025-02-27 14:29:32 98 + 99 2025-02-27 14:29:32 99 + 100 2025-02-27 14:29:32 100 + 101 2025-02-27 14:29:32 101 + 102 2025-02-27 14:29:32 102 + 103 2025-02-27 14:29:32 103 + 104 2025-02-27 14:29:32 104 + 105 2025-02-27 14:29:32 105 + 106 2025-02-27 14:29:32 106 + 107 2025-02-27 14:29:32 107 + 108 2025-02-27 14:29:32 108 + 109 2025-02-27 14:29:32 109 + 110 2025-02-27 14:29:32 110 + 111 2025-02-27 14:29:32 111 + 112 2025-02-27 14:29:32 112 + 113 2025-02-27 14:29:32 113 + 114 2025-02-27 14:29:32 114 + 115 2025-02-27 14:29:32 115 + 116 2025-02-27 14:29:32 116 + 117 2025-02-27 14:29:32 117 + 118 2025-02-27 14:29:32 118 + 119 2025-02-27 14:29:32 119 + 120 2025-02-27 14:29:32 120 + 121 2025-02-27 14:29:32 121 + 122 2025-02-27 14:29:32 122 + 123 2025-02-27 14:29:32 123 + 124 2025-02-27 14:29:32 124 + 125 2025-02-27 14:29:32 125 + 126 2025-02-27 14:29:32 126 + 127 2025-02-27 14:29:32 127 + 128 2025-02-27 14:29:32 128 + 129 2025-02-27 14:29:32 129 + 130 2025-02-27 14:29:32 130 + 131 2025-02-27 14:29:32 131 + 132 2025-02-27 14:29:32 132 + 133 2025-02-27 14:29:32 133 + 134 2025-02-27 14:29:32 134 + 135 2025-02-27 14:29:32 135 + 136 2025-02-27 14:29:32 136 + 137 2025-02-27 14:29:32 137 + 138 2025-02-27 14:29:32 138 + 139 2025-02-27 14:29:32 139 + 140 2025-02-27 14:29:32 140 + 141 2025-02-27 14:29:32 141 + 142 2025-02-27 14:29:32 142 + 143 2025-02-27 14:29:32 143 + 144 2025-02-27 14:29:32 144 + 145 2025-02-27 14:29:32 145 + 146 2025-02-27 14:29:32 146 + 147 2025-02-27 14:29:32 147 + 148 2025-02-27 14:29:32 148 + 149 2025-02-27 14:29:32 149 + 150 2025-02-27 14:29:32 150 diff --git a/tests/testthat/_snaps/8-commenter_champs.md b/tests/testthat/_snaps/8-commenter_champs.md index cff8b0f0391540448f882d2f8d7b45fbaea76c39..46dc5305e0a7a94e7ce372923ec579f5214920da 100644 --- a/tests/testthat/_snaps/8-commenter_champs.md +++ b/tests/testthat/_snaps/8-commenter_champs.md @@ -4,8 +4,10 @@ get_table_comment(table = "test_iris", schema = "public", db = "test_datalibaba", user = "test", server = Sys.getenv("server")) Output - nom_schema nom_table commentaire - 1 public test_iris NA + nom_schema nom_table + 1 public test_iris + commentaire + 1 la table de test complete\nCommentaire posté le 27/02/2025, par edouard.morin. # get_cols_comment works @@ -13,12 +15,8 @@ get_cols_comment(table = "test_iris", schema = "public", db = "test_datalibaba", user = "test", server = Sys.getenv("server")) Output - nom_schema nom_table nom_col commentaire - 1 public test_iris sepal_length libellé de Sepal.Length cc - 2 public test_iris sepal_width libellé de Sepal.Width cc - 3 public test_iris petal_length libellé de Petal.Length cc - 4 public test_iris petal_width libellé de Petal.Width cc - 5 public test_iris species Commentlibaba ! + nom_schema nom_table nom_col commentaire + 1 public test_iris species Commentlibaba ! # get_table_comments works @@ -26,11 +24,13 @@ get_table_comments(table = "test_iris", schema = "public", db = "test_datalibaba", user = "test", server = Sys.getenv("server")) Output - nom_schema nom_table commentaire nom_col - 1 public test_iris NA <NA> - 2 public test_iris libellé de Sepal.Length cc sepal_length - 3 public test_iris libellé de Sepal.Width cc sepal_width - 4 public test_iris libellé de Petal.Length cc petal_length - 5 public test_iris libellé de Petal.Width cc petal_width - 6 public test_iris Commentlibaba ! species + nom_schema nom_table + 1 public test_iris + 2 public test_iris + commentaire + 1 la table de test complete\nCommentaire posté le 27/02/2025, par edouard.morin. + 2 Commentlibaba ! + nom_col + 1 <NA> + 2 species diff --git a/tests/testthat/test-4-post_data.R b/tests/testthat/test-4-post_data.R index 77519b735d51f7577b2ed00a0ba2931a78bd73f1..c6ebc425ee4f43c3cc2b5a2501e369ab059ae06c 100644 --- a/tests/testthat/test-4-post_data.R +++ b/tests/testthat/test-4-post_data.R @@ -5,6 +5,7 @@ library(lubridate) library(dplyr) library(sf) library(glue) +library(backports) test_that("poster_data works", { if(DBI::dbCanConnect(RPostgres::Postgres(), host="localhost", user="runner", password=Sys.getenv("BDD_RUNNER_PWD"), dbname="postgres")){ @@ -13,6 +14,32 @@ test_that("poster_data works", { Sys.setenv(user_test="runner") Sys.setenv(pwd_test=Sys.getenv("BDD_RUNNER_PWD")) + # test list_tables (utilise dans poster_data) + schem <- paste0("test_listdata_",sample.int(1000, 1)) + condirect <- DBI::dbConnect(RPostgres::Postgres(), host="localhost", user="runner", password=Sys.getenv("BDD_RUNNER_PWD"), dbname="test_datalibaba") + DBI::dbExecute(condirect, paste0("CREATE SCHEMA ",schem," AUTHORIZATION runner;")) + DBI::dbExecute(condirect, paste0("GRANT ALL ON SCHEMA ",schem," TO runner WITH GRANT OPTION;")) + DBI::dbExecute(condirect, paste0("ALTER DEFAULT PRIVILEGES IN SCHEMA ",schem," GRANT ALL ON TABLES TO runner;")) + DBI::dbExecute(condirect, paste0("ALTER DEFAULT PRIVILEGES IN SCHEMA ",schem," GRANT ALL ON SEQUENCES TO runner;")) + expect_snapshot(list_tables(schema = schem, db = "test_datalibaba", user = "test")) + con<<-connect_to_db(db = 'test_datalibaba', user = 'test') + expect_snapshot(list_tables(schema = schem, con = con)) + }else{ + print(DBI::dbCanConnect(RPostgres::Postgres(), host="localhost", user="runner", password=Sys.getenv("BDD_RUNNER_PWD"), dbname="postgres")) + print('warning: connect_to_db - local database postgresql doesnt work !') + expect_equal(1,1) + } +}) + +test_that("poster_data works", { + if(DBI::dbCanConnect(RPostgres::Postgres(), host="localhost", user="runner", password=Sys.getenv("BDD_RUNNER_PWD"), dbname="postgres")){ + Sys.setenv(port="5432") + Sys.setenv(server="localhost") + Sys.setenv(user_test="runner") + Sys.setenv(pwd_test=Sys.getenv("BDD_RUNNER_PWD")) + + #tests poster_data + expect_error(poster_data(table = "test_iris", schema = "public", db = "test_datalibaba", pk = NULL, post_row_name = FALSE, overwrite = TRUE, user = "test"), "'data' n\'est pas renseign\u00e9") @@ -30,10 +57,14 @@ test_that("poster_data works", { "table n\'est pas renseign\u00e9") # test création schema, post_row_name, ecoSQL, pk et overwrite + schem <- paste0("test_",sample.int(1000, 1),"_",sample.int(1000, 1)) + expect_warning(poster_data(data = iris, table = "test_iris", schema = schem, db = "test_datalibaba", pk = NULL, post_row_name = TRUE, overwrite = TRUE, user = "test"), paste0("le schema ",schem," n\\'existe pas\\. Il va être créé sous test_datalibaba\\.")) - df<-iris %>% rownames_to_column("id") %>% mutate(todate = now(tzone = "UTC")) + + df<-iris %>% rownames_to_column("id") %>% mutate(todate = parse_date_time("2025-02-27 14:29:32", "Ymd HMS")) + expect_message(poster_data(data = df, table = "test_iris", schema = "public", db = "test_datalibaba", pk = "id", post_row_name = TRUE, overwrite = TRUE, user = "test", ecoSQL = FALSE), "\u00e9crit dans la table ") expect_message(poster_data(data = df, table = "test_iris", schema = "public", db = "test_datalibaba", pk = 1, post_row_name = TRUE, overwrite = TRUE, user = "test"), @@ -46,7 +77,6 @@ test_that("poster_data works", { expect_message(poster_data(data = nc, table = "nc", schema = "public", db = "test_datalibaba", pk = NULL, post_row_name = FALSE, overwrite = TRUE, user = "test"), "\u00e9crit dans la table ") - }else{ print(DBI::dbCanConnect(RPostgres::Postgres(), host="localhost", user="runner", password=Sys.getenv("BDD_RUNNER_PWD"), dbname="postgres")) print('warning: connect_to_db - local database postgresql doesnt work !') @@ -100,7 +130,7 @@ test_that("post_data_dbi works", { Sys.setenv(user_test="runner") Sys.setenv(pwd_test=Sys.getenv("BDD_RUNNER_PWD")) con<<-connect_to_db(db = 'test_datalibaba', user = 'test', ecoSQL = FALSE) - expect_message(post_data_dbi(con, data = iris, schema = "public", table = "retest_iris", overwrite = TRUE), + expect_message(suppressWarnings(post_data_dbi(con, data = iris, schema = "public", table = "retest_iris", overwrite = TRUE)), " est \u00e9cras\u00e9e sur le schema ") }else{ print(DBI::dbCanConnect(RPostgres::Postgres(), host="localhost", user="runner", password=Sys.getenv("BDD_RUNNER_PWD"), dbname="postgres")) diff --git a/tests/testthat/test-5-get_data.R b/tests/testthat/test-5-get_data.R index 1684c63838e8fda3da1078e9b28529ee0a34cd6d..a8333844a9bbb3fea7b03d764edce3b67c902bbd 100644 --- a/tests/testthat/test-5-get_data.R +++ b/tests/testthat/test-5-get_data.R @@ -48,9 +48,6 @@ test_that("importer_data works", { expect_snapshot(importer_data(table = "test_nc_noid", schema = "public", db = "test_datalibaba", user = "test", limit = 4)) #A FINIR !!! - #test list_tables - expect_snapshot(list_tables(schema = "public", db = "test_datalibaba", user = "test")) - }else{ print(DBI::dbCanConnect(RPostgres::Postgres(), host="localhost", user="runner", password=Sys.getenv("BDD_RUNNER_PWD"), dbname="postgres")) print('warning: connect_to_db - local database postgresql doesnt work !')