[Rd] S4 coercion

Paul Gilbert pgilbert at bank-banque-canada.ca
Wed Aug 27 16:03:29 CEST 2008

I am extending a DBI connection by


but the first time I use this I am getting a warning when it tries to 
coerce  the  TSPostgreSQLConnection to a PostgreSQLConnection. After the 
first use the warning stops,  but the first warning is causing me 
problems when I do automatic checks and set my tests to stop on 
warnings. (I think there should be a correct way to do this that does 
not produce a warning.)  I can trace it back by setting options(warn=2) 
as below.  Do I need to be more specific about how the coercion  
happens? If so, what is the correct way to coerce the 
TSPostgreSQLConnection into a PostgreSQLConnection? If not, how to a get 
rid of the warning?

Paul Gilbert

 > TSdelete("vec", con)
Error: (converted from warning) Ambiguous method selection for "coerce", 
target "TSPostgreSQLConnection#integer" (the first of the signatures 
shown will be used)
 > traceback()
15: doWithOneRestart(return(expr), restart)
14: withOneRestart(expr, restarts[[1]])
13: withRestarts({
       .Internal(.signalCondition(simpleWarning(msg, call), msg,
       .Internal(.dfltWarn(msg, call))
   }, muffleWarning = function() NULL)
12: .signalSimpleWarning("Ambiguous method selection for \"coerce\", 
target \"TSPostgreSQLConnection#integer\" (the first of the signatures 
shown will be used)\n    PostgreSQLConnection#integer\n    
11: warning(gettextf(paste("Ambiguous method selection for \"%s\", 
target \"%s\"",
       "(the first of the signatures shown will be used)\n%s\n"),
       fdef at generic, .sigLabel(classes), paste("   ", names(methods),
           collapse = "\n")), domain = NA, call. = FALSE)
10: .findInheritedMethods(signature, fdef, mtable = allmethods, table = 
       useInherited = useInherited, verbose = verbose)
9: selectMethod("coerce", sig, optional = TRUE, c(from = TRUE, to = FALSE),
      fdef = coerceFun, mlist = coerceMethods)
8: as(obj, "integer")
7: isIdCurrent(con)
6: postgresqlQuickSQL(conn, statement, ...)
5: dbGetQuery(con, paste("SELECT tbl  FROM Meta ", where, ";"))
4: dbGetQuery(con, paste("SELECT tbl  FROM Meta ", where, ";"))
3: TSdbi:::TSdeleteSQL(serIDs = serIDs, con = con, ...)
2: TSdelete("vec", con)
1: TSdelete("vec", con)
 >  str(con)
Formal class 'TSPostgreSQLConnection' [package "TSPostgreSQL"] with 4 slots
 ..@ Id     : int [1:2] 21795 1
 ..@ dbname : chr "test"
 ..@ vintage: logi FALSE
 ..@ panel  : logi FALSE

La version française suit le texte anglais.


This email may contain privileged and/or confidential in...{{dropped:26}}

More information about the R-devel mailing list