From seth at userprimary.net  Thu Sep 18 06:21:10 2008
From: seth at userprimary.net (Seth Falcon)
Date: Wed, 17 Sep 2008 21:21:10 -0700
Subject: [Rd] S4 coercion responsibility
In-Reply-To: <20080918040619.GF511@ziti.local>
References: <48CE5B66.1050705@bank-banque-canada.ca>
	<20080915170741.GX33406@ziti.local>
	<20080918022502.GB511@ziti.local> <20080918040619.GF511@ziti.local>
Message-ID: <20080918042110.GH511@ziti.local>

Continuing to talk to myself here...

* On 2008-09-17 at 21:06 -0700 Seth Falcon wrote:
> *argh* I'm certain this was working for me and yet when I try to
> reproduce in a new R shell it errors out.

This looks like an infelicity in the methods caching.

To make it work:

    library("RSQLite")
    setClass("SQLConPlus", contains=c("SQLiteConnection","integer"))
    dd = data.frame(a=1:3, b=letters[1:3])
    con.orig = dbConnect(SQLite(), ":memory:")
    con = new("SQLConPlus", con.orig, 11L)

    ## call selectMethod, must have a side-effect on the
    ## methods cache
    selectMethod(coerce, signature=c("SQLConPlus", "integer"))

    dbWriteTable(con, "t1", dd)
    dbListTables(con)
    dbDisconnect(con)

Now I get:

    as(con, "integer")
    [1] 15719     0

Haven't tried the above in an older version of R.

-- 
Seth Falcon | http://userprimary.net/user/



[Rd] S4 coercion responsibility
Seth Falcon