Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use string as default for unknown column type #260

Merged
merged 9 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/MariaTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
bool all_raw(SEXP x);

MariaFieldType variable_type_from_field_type(enum_field_types type, bool binary, bool length1) {

switch (type) {
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
Expand Down Expand Up @@ -53,7 +54,8 @@ MariaFieldType variable_type_from_field_type(enum_field_types type, bool binary,
case MYSQL_TYPE_NULL:
return MY_INT32;
default:
cpp11::stop("Unimplemented MAX_NO_FIELD_TYPES: %d", type);
cpp11::warning("unrecognized field type %i imported as character", type);
return MY_STR;
}
}

Expand Down
11 changes: 6 additions & 5 deletions tests/testthat/test-dbWriteTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ test_that("writing and reading JSON (#127)", {
x <- data.frame(col1 = "[1,2,3]", stringsAsFactors = FALSE)

dbWriteTable(con, "t1", x, field.types = c(col1 = "json"), overwrite = TRUE, temporary = TRUE)
dbReadTable(con, "t1")

expect_equal(
gsub(" ", "", dbReadTable(con, "t1")$col1),
x$col1
)
suppressWarnings(d <- dbReadTable(con, "t1"))

# MySQL 8 returns "[1, 2, 3]", while MariaDB returns "[1,2,3]"
d$col1 <- gsub('\\s', '', d$col1)

expect_equal(d, x)
})
Loading