Skip to content

Commit 12024e2

Browse files
committed
clean up the code a little bit
1 parent 5f385ae commit 12024e2

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/scan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void AppendAnyColumnSegment(const RType &rtype, bool experimental, data_ptr_t co
153153
utf8proc_option_t options = (UTF8PROC_NULLTERM);
154154
auto res = utf8proc_map(str, 0, &new_string, options);
155155
if (res == UTF8PROC_ERROR_INVALIDUTF8) {
156-
throw InternalException("rapi_execute: Cannot process strings that are not valid utf8: %s", string_val);
156+
throw InvalidInputException("Strings \"%s\" is not valid utf8", (char*)string_val);
157157
}
158158

159159
if (experimental) {

tests/testthat/test_strings.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
library(duckdb)
2+
13
test_that("Invalid unicode produces an error", {
2-
con <- dbConnect(duckdb())
3-
on.exit(dbDisconnect(con, shutdown = TRUE))
4+
con <- DBI::dbConnect(duckdb::duckdb())
45

56
my_df <- structure(list(no_municipio_esc = "Est\xe2ncia", no_municipio_prova = "Est\xe2ncia"), row.names = 16L, class = "data.frame")
6-
expect_error(DBI::dbWriteTable( con , 'my_table' , my_df ), "Cannot process strings that are not valid", ignore.case = TRUE)
7+
expect_error(dbWriteTable(con , 'my_table' , my_df ))
8+
9+
# test that the connection still works.
10+
dbWriteTable(con, 'myTable', data.frame(a=c(1, 2, 3), b=c(4, 5, 6)))
11+
DBI::dbDisconnect(con, shutdown = TRUE)
712
})

0 commit comments

Comments
 (0)