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

Fix the datanames bug causing teal app to crash when teal_data has non standard object names #1367

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions R/module_init_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ srv_init_data <- function(id, data) {
)

tdata@verified <- data@verified
if (length(datanames(data))) {
datanames(tdata) <- datanames(data)
}
tdata
}

Expand Down
4 changes: 3 additions & 1 deletion R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@ srv_teal_module.teal_module <- function(id,

.resolve_module_datanames <- function(data, modules) {
stopifnot("data_rv must be teal_data object." = inherits(data, "teal_data"))
if (is.null(modules$datanames) || identical(modules$datanames, "all")) {
if (length(datanames(data))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this can be a first condition. If datanames are not null then other conditions will be ignored.

.topologically_sort_datanames(datanames(data), teal.data::join_keys(data))
} else if (is.null(modules$datanames) || identical(modules$datanames, "all")) {
.topologically_sort_datanames(ls(teal.code::get_env(data)), teal.data::join_keys(data))
} else {
intersect(
Expand Down
5 changes: 4 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ get_teal_bs_theme <- function() {
#' @param datanames (`character`) vector of data set names to include; must be subset of `datanames(x)`
#' @return A `FilteredData` object.
#' @keywords internal
teal_data_to_filtered_data <- function(x, datanames = ls(teal.code::get_env(x))) {
teal_data_to_filtered_data <- function(x, datanames = teal.data::datanames(data)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can instead relax the assertion on datanames in teal.slice?

checkmate::assert_class(x, "teal_data")
checkmate::assert_character(datanames, min.chars = 1L, any.missing = FALSE)
# Otherwise, FilteredData will be created in the modules' scope later
if (!length(datanames)) {
datanames <- ls(teal.code::get_env(x))
}
teal.slice::init_filtered_data(
x = Filter(
length,
Expand Down
2 changes: 1 addition & 1 deletion man/teal_data_to_filtered_data.Rd

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

Loading