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
allow non-factor statnames in utils::transformstats #2545
allow non-factor statnames in utils::transformstats #2545
Conversation
I still don't understand travis well enough to know what to do with the travis failure - the log says "build exited with status 1" indicating success, but then travis says the build fails https://travis-ci.org/github/PecanProject/pecan/jobs/664465417?utm_medium=notification&utm_source=github_status |
@dlebauer the statuses are from bash, so anything not 0 is a failure. Looks like this is yet another unrelated dependency failure, this time in the DB tests: apparently |
As I mentioned on Slack, I think the easiest fix here is to replace the insert_string <- paste(insert_list, collapse = ",")
result <- glue::glue_sql(
"INSERT INTO {`table`} ({`colnames(values)`*}) VALUES ",
.con = .con
)
DBI::SQL(paste0(result, "(", insert_string, ")")) It feel like a less-robust solution because it replaces supposedly robust backend-dependent SQL quoting with hard-coded quoting...but I think it should work with the SQLite backend in the test. Also as I mentioned on Slack, the ideal solution here is to simplify the code in that script to just use prepared statements for everything, which should be faster, safer, and easier to implement. |
Description
PEcAn.utils::transformstats
currently assumes thestatname
column if its input is a factor. This patch allows it to be character instead, if desired. Output keeps the same class it had on input.Edit: while I was here, also cleaned up code formatting and fixed logic in the untransformed stats warning.
Motivation and Context
Noticed now because the development version of R no longer coerces character vectors in
data.frame
to factor, so our unit test started failing. Good catch, unit test!Review Time Estimate
Types of changes
Checklist: