From 9342209541700c26606972c15053beac805109ac Mon Sep 17 00:00:00 2001 From: Thomas Roh Date: Mon, 15 Apr 2024 13:41:25 -0700 Subject: [PATCH 1/4] speed up dt conversion for spatial files --- R/bcp.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/bcp.R b/R/bcp.R index 31a27c3..79383c9 100644 --- a/R/bcp.R +++ b/R/bcp.R @@ -119,7 +119,7 @@ bcpImport <- function( } geometryCol <- attr(x, 'sf_column') binaryCol <- sprintf('%sWkb', geometryCol) - x <- data.table::data.table(x) + data.table::setDT(x) data.table::set(x = x, j = binaryCol, value = sf::st_as_binary(x[[geometryCol]], hex = TRUE)) data.table::set(x = x, j = geometryCol, value = NULL) From 90008b5a4433fa81ef6e4741ee5d794cc09e2975 Mon Sep 17 00:00:00 2001 From: Thomas Roh Date: Mon, 15 Apr 2024 13:43:13 -0700 Subject: [PATCH 2/4] throw error for edge case of srid is NA --- R/bcp.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/bcp.R b/R/bcp.R index 79383c9..1a9c201 100644 --- a/R/bcp.R +++ b/R/bcp.R @@ -113,7 +113,7 @@ bcpImport <- function( if (isSpatial) { spatialtype <- match.arg(spatialtype) srid <- sf::st_crs(x)$epsg - if (is.null(srid) || !is.numeric(srid)) { + if (is.null(srid) || !is.numeric(srid) || is.na(srid)) { stop('Only EPSGs are supported for SQL Server SRIDs. Check with sf::st_crs and change projection with sf::st_transform.') } From d27cf79e0db621b124af41f34e67aae54605920b Mon Sep 17 00:00:00 2001 From: Thomas Roh Date: Mon, 15 Apr 2024 14:03:15 -0700 Subject: [PATCH 3/4] Revert "speed up dt conversion for spatial files" This reverts commit 9342209541700c26606972c15053beac805109ac. --- R/bcp.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/bcp.R b/R/bcp.R index 1a9c201..6fdbf2f 100644 --- a/R/bcp.R +++ b/R/bcp.R @@ -119,7 +119,7 @@ bcpImport <- function( } geometryCol <- attr(x, 'sf_column') binaryCol <- sprintf('%sWkb', geometryCol) - data.table::setDT(x) + x <- data.table::data.table(x) data.table::set(x = x, j = binaryCol, value = sf::st_as_binary(x[[geometryCol]], hex = TRUE)) data.table::set(x = x, j = geometryCol, value = NULL) From 6d16dd545d3ddd5cc3c90bbdcd5fe365791104f2 Mon Sep 17 00:00:00 2001 From: Thomas Roh Date: Mon, 15 Apr 2024 14:12:55 -0700 Subject: [PATCH 4/4] docs --- DESCRIPTION | 2 +- NEWS.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b9d7567..57ac5dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: bcputility Type: Package Title: Wrapper for SQL Server bcp Utility -Version: 0.4.2 +Version: 0.4.3 Authors@R: person("Thomas", "Roh", email = "thomas@roh.engineering", role = c("aut", "cre")) Description: Provides functions to utilize a command line utility that does bulk inserts and exports from SQL Server databases. License: MIT + file LICENSE diff --git a/NEWS.md b/NEWS.md index a1b0f1c..71de574 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,6 @@ -# bcputility 0.4.2 +# bcputility 0.4.3 + +* An error is now thrown for cases where a projection has an EPSG that is `NA`. * Added ability to turn on QUOTED_IDENTIFIERS. This is required for some Microsoft database products. Use the bcp "-q" option.