From pgilbert at bank-banque-canada.ca  Mon Sep 15 14:56:06 2008
From: pgilbert at bank-banque-canada.ca (Paul Gilbert)
Date: Mon, 15 Sep 2008 08:56:06 -0400
Subject: [Rd] S4 coercion responsibility
Message-ID: <48CE5B66.1050705@bank-banque-canada.ca>

Should functions or the user be responsible for coercing an S4 object 
argument containing the proper object (and thus should below be 
considered a bug in the packages or not)?

The example is  with RSQLite but the same thing happens with RMySQL, and 
other DBI packages.

 > library("RSQLite")  Loading required package: DBI
 > m <- dbDriver("SQLite")
 > con <- dbConnect(m)
 > setClass("SQLConPlus", contains=c("SQLiteConnection","integer"))
[1] "SQLConPlus"
 > conPlus <- new("SQLConPlus", con, 1)
 > dbListTables(con)
character(0)
 > dbListTables(conPlus)
Error in sqliteExecStatement(con, statement, bind.data) :
 RS-DBI driver: (invalid dbManager handle)
 > dbListTables(as(conPlus, "SQLiteConnection"))
character(0)
 >

The problem is happening in sqliteExecStatement which does
   conId <- as(con, "integer")
but con only *contains* an SQLiteConnection and the other integer
causes confusion. If the line were
   conId <- as(as(con, "SQLiteConnection"), "integer")
everything works.

I can work around this, but I am curious where  responsibility for this 
coercion should be.

Paul Gilbert
====================================================================================

La version fran?aise suit le texte anglais.

------------------------------------------------------------------------------------

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



[Rd] S4 coercion responsibility
Paul Gilbert