[Rd] S4 coercion

From: Paul Gilbert <pgilbert_at_bank-banque-canada.ca>
Date: Wed, 27 Aug 2008 10:03:29 -0400

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 dbObjectId#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 = mlist,

       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}}

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 27 Aug 2008 - 14:05:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 27 Aug 2008 - 17:37:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive