Skip to content

Commit

Permalink
Fixing issues when fetching dates from SQLite. Fixes #150
Browse files Browse the repository at this point in the history
  • Loading branch information
schuemie committed Jul 29, 2021
1 parent 49a55c1 commit 8071b0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ Changes:

2. Reusing byte buffer when passing 64-bit integers from Java to R for efficiency.

3. Adding support for SQLite with extended types (DATE and DATETIME), with `dbms = 'sqlite extended'`.

4. Adding support for connecting to Spark.
3. Adding support for connecting to Spark.

Bugfixes:

1. Fixing field type of numeric fields on Oracle when fetching data.

2. Fixing issues when fetching dates from SQLite (needed casting to numeric in some scenarios before conversion to date in R).


DatabaseConnector 4.0.2
=======================
Expand Down
5 changes: 2 additions & 3 deletions R/Sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,11 @@ convertFields <- function(dbms, result) {
if (dbms == "sqlite") {
for (colname in colnames(result)) {
if (grepl("DATE$", colname)) {
result[[colname]] <- as.Date(as.POSIXct(result[[colname]], origin = "1970-01-01", tz = "GMT"))
result[[colname]] <- as.Date(as.POSIXct(as.numeric(result[[colname]]), origin = "1970-01-01", tz = "GMT"))
}
if (grepl("DATETIME$", colname)) {
result[[colname]] <- as.POSIXct(result[[colname]], origin = "1970-01-01", tz = "GMT")
result[[colname]] <- as.POSIXct(as.numeric(result[[colname]]), origin = "1970-01-01", tz = "GMT")
}

}
}
if (dbms %in% c("bigquery")) {
Expand Down

0 comments on commit 8071b0a

Please sign in to comment.