From ff016fd1311ab6e525deb066616383aa8f9c3233 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Fri, 4 Oct 2024 13:13:16 +0100 Subject: [PATCH] Sysobjects qry fix (#66) * SQL comment wrapping error * fix show tables ut --- R/show_schema_tables.R | 3 ++- tests/testthat/test-show_schema_tables.R | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/R/show_schema_tables.R b/R/show_schema_tables.R index 3ddcfb7..bd99123 100644 --- a/R/show_schema_tables.R +++ b/R/show_schema_tables.R @@ -6,12 +6,13 @@ table_sql <- function(schema) { order by 2;", .con = DBI::ANSI()) } +# type IN ('U', 'V') = user tables, views table_view_sql <- function(schema) { glue::glue_sql("SELECT name AS 'table', \\ type_desc AS 'object_type', \\ create_date AS 'creation_date' \\ FROM sys.objects \\ - WHERE type IN ('U', 'V') -- 'U'ser tables, 'V'iews \\ + WHERE type IN ('U', 'V') \\ AND SCHEMA_NAME(schema_id) = {schema} \\ order by type, name;", .con = DBI::ANSI()) } diff --git a/tests/testthat/test-show_schema_tables.R b/tests/testthat/test-show_schema_tables.R index d7a0f79..f546d4b 100644 --- a/tests/testthat/test-show_schema_tables.R +++ b/tests/testthat/test-show_schema_tables.R @@ -15,7 +15,7 @@ test_that("table and view sql created correctly", { type_desc AS 'object_type', \\ create_date AS 'creation_date' \\ FROM sys.objects \\ - WHERE type IN ('U', 'V') -- 'U'ser tables, 'V'iews \\ + WHERE type IN ('U', 'V') \\ AND SCHEMA_NAME(schema_id) = 'test_schema' \\ order by type, name;")