Skip to content

Commit

Permalink
sql server: Roundtrip of hms data (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
detule authored Feb 3, 2025
1 parent 1e81ed2 commit f7ba147
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# odbc (development version)

* SQL Server: Fix roundtrip of `hms` data.

* SQL Server: Fix data truncation when writing to temp tables with
`FreeTDS` (#866).

Expand Down
4 changes: 4 additions & 0 deletions src/odbc_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <chrono>
#include <memory>

#ifndef SQL_SS_TIME2
#define SQL_SS_TIME2 (-154)
#endif
namespace odbc {

using odbc::utils::run_interruptible;
Expand Down Expand Up @@ -691,6 +694,7 @@ std::vector<r_type> odbc_result::column_types(nanodbc::result const& r) {
break;
// Time
case SQL_TIME:
case SQL_SS_TIME2:
case SQL_TYPE_TIME:
types.push_back(odbc::time_t);
break;
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-driver-sql-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,7 @@ test_that("DATETIME2 precision (#790)", {
res <- DBI::dbReadTable(con, tbl)
expect_equal(as.POSIXlt(df[[2]])$sec, as.POSIXlt(res[[2]])$sec, tolerance = 1E-7)
})

test_that("package:odbc roundtrip test", {
test_roundtrip(test_con("SQLSERVER"))
})

0 comments on commit f7ba147

Please sign in to comment.