I have a .R file that contains several functions, one of which is defined as:
get_entry_detail <- function(con, vec_of_entryids){
query <- paste0("select entryId, fieldName, fieldValue
from `hthu-eligibility`.entry_detail
where entryId in (", paste(vec_of_entryids, collapse = ","), ");")
dbGetQuery(con, query) %>%
mutate(fieldName = ifelse(fieldName == "firstName",
gsub(paste(c(""), collapse = "|"), "", fieldName),
fieldName))
}
Note that there is a mutate() that strips off a  when fieldName == "firstName".
I source() this file at the top of another .R file but when I view the function after sourcing the file, the function has changed to:
> source("R/get_join_employee_data_userid.R")
> get_entry_detail
function(con, vec_of_entryids){
query <- paste0("select entryId, fieldName, fieldValue
from `hthu-eligibility`.entry_detail
where entryId in (", paste(vec_of_entryids, collapse = ","), ");")
dbGetQuery(con, query) %>%
mutate(fieldName = ifelse(fieldName == "firstName",
gsub(paste(c(""), collapse = "|"), "", fieldName),
fieldName))
}
And the  has now changed to . This causes later functions to fail because there is no  that needs to be removed thus later joins fail.
How do I prevent this from happening? I can't adjust the database structure.