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

Closes #226 - metadata is no longer inferred on xportr_write #227

Merged
merged 1 commit into from
Jan 29, 2024
Merged
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
6 changes: 4 additions & 2 deletions R/write.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#' @param strict_checks If TRUE, xpt validation will report errors and not write
#' out the dataset. If FALSE, xpt validation will report warnings and continue
#' with writing out the dataset. Defaults to FALSE
#' @inheritParams xportr_length
#' @inheritParams xportr_df_label
#' @inheritSection xportr_df_label Metadata
Comment on lines +15 to +16
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

metadata parameter should be the same as xportr_df_label (Metacore or with dataset name)

#'
#' @details
#' * Variable and dataset labels are stored in the "label" attribute.
Expand Down Expand Up @@ -67,7 +68,8 @@ xportr_write <- function(.df,
domain <- domain %||% attr(.df, "_xportr.df_arg_")
if (!is.null(domain)) attr(.df, "_xportr.df_arg_") <- domain

metadata <- metadata %||% attr(.df, "_xportr.df_metadata_")
# metadata should not be inferred from the data frame if it is not provided
# by the user.
Comment on lines +71 to +72
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alternatively, we could infer *only* if it's a metacore instance.

Suggested change
# metadata should not be inferred from the data frame if it is not provided
# by the user.
# metadata should only be inferred from the data frame if it is a `Metacore` object
metadata_tmp <- metadata %||% attr(.df, "_xportr.df_metadata_")
if (inherits(metadata_tmp, "Metacore")) metadata <- metadata_tmp


## End of common section

Expand Down
20 changes: 18 additions & 2 deletions man/xportr_write.Rd

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

Loading