Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Namespace for cbind not set correctly #54

Open
iyerr3 opened this issue Jun 16, 2017 · 0 comments
Open

Namespace for cbind not set correctly #54

iyerr3 opened this issue Jun 16, 2017 · 0 comments

Comments

@iyerr3
Copy link
Contributor

iyerr3 commented Jun 16, 2017

Bug report from Mark Malamut:

I believe I encountered what appears to be a small bug in this package that I cannot get around when trying to incorporate it into my own package which provides a db access layer for our team. Here is what I believe is the problem.

Note that I am using the most recent version from CRAN 0.1.18.3

The PivotalR package implements cbind and therefore overrides the base cbind when the fully library is loaded using the library(PivotalR) directive. From the behavior I have seen it appears that a reference to cbind in your package uses whatever cbind is available in the current environment as opposed to explicitly using PivotalR::cbind. I believe this to be the case as my code works fine when specifying library(PivotalR) but fails during db.disconnect with the following when the library is not fully loaded.

Sample Code

#library(PivotalR)
 
connect = function(){
  PivotalR::db.connect(host='x1', user='x2', password='x3', dbname='x4', quick=TRUE)
}
 
disconnect = function(id){
  PivotalR::db.disconnect(conn.id=id, verbose=TRUE)
}
 
query = function(str){
  id = connect()
  result = PivotalR::db.q(str, conn.id=id, verbose=TRUE, nrows='all')
  disconnect(id)
 
  result
}
 
X = query(“SELECT * FROM <table>”)
Error in .localVars$conn.type[[conn.pkg]] <- .localVars$conn.type[[conn.pkg]][-which(.localVars$conn.type[[conn.pkg]] == : replacement has length zero
 
 
 
When the library PivotalR is loaded, I see the following informational messages and my code works without error:
> library("PivotalR", lib.loc="~/R/win-library/3.3")
 
Attaching package: ‘PivotalR’
 
The following objects are masked from ‘package:stats’:
 
    sd, var
 
The following object is masked from ‘package:base’:
 
    cbind

Which is why I believe there is an implicit call to cbind in your code ( It doesn’t seem that sd or var are the issue). Note that the first time it fails in db.disconnect but if you rerun without resetting the environment subsequent calls will fail in db.connect with the following error message:

Error in .localVars$conn.type[["rpostgresql"]] <- c(.localVars$conn.type[["rpostgresql"]], : more elements supplied than there are to replace
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant