Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude information_schema tables from dm by default if schema = NULL #1130

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R/dm_from_con.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#'
#' - `schema`: supported for MSSQL (default: `"dbo"`), Postgres (default: `"public"`), and MariaDB/MySQL
#' (default: current database). Learn the tables in a specific schema (or database for MariaDB/MySQL).
#' If NULL, tables from `"information_schema"` are not included.
#' - `dbname`: supported for MSSQL. Access different databases on the connected MSSQL-server;
#' default: active database.
#' - `table_type`: supported for Postgres (default: `"BASE TABLE"`). Specify the table type. Options are:
Expand Down
11 changes: 11 additions & 0 deletions R/meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ filter_dm_meta <- function(dm_meta, catalog = NULL, schema = NULL) {
table_constraints <- table_constraints %>% filter(table_schema %in% !!schema)
key_column_usage <- key_column_usage %>% filter(table_schema %in% !!schema)
constraint_column_usage <- constraint_column_usage %>% filter(table_schema %in% !!schema)
} else {
schemata <- schemata %>% filter(schema_name != "information_schema")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need tolower() here and everywhere?

tables <- tables %>% filter(table_schema != "information_schema")
columns <- columns %>% filter(table_schema != "information_schema")
table_constraints <- table_constraints %>% filter(table_schema != "information_schema")
key_column_usage <- key_column_usage %>% filter(table_schema != "information_schema")
constraint_column_usage <- constraint_column_usage %>% filter(table_schema != "information_schema")
}

dm(
Expand Down Expand Up @@ -285,6 +292,10 @@ filter_dm_meta_simple <- function(dm_meta, catalog = NULL, schema = NULL) {
schemata <- schemata %>% filter(schema_name %in% !!schema)
tables <- tables %>% filter(table_schema %in% !!schema)
columns <- columns %>% filter(table_schema %in% !!schema)
} else {
schemata <- schemata %>% filter(schema_name != "information_schema")
tables <- tables %>% filter(table_schema != "information_schema")
columns <- columns %>% filter(table_schema != "information_schema")
}

dm(schemata, tables, columns) %>%
Expand Down
1 change: 1 addition & 0 deletions man/dm_from_con.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dm_from_src.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.