[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] DBI FieldConverter and what to throw away

From: Holger Hans Peter Freyther
Subject: [Help-smalltalk] DBI FieldConverter and what to throw away
Date: Mon, 20 May 2013 08:55:02 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Dear Paolo,

the DBI.FieldConverter has a funny thing in the conversion lookup
from Smalltalk to Database Type. The look-up is based on classes
and this doesn't really work for Boolean and Integer.


st> FieldConverter uniqueInstance print: true on: stdout

will not go through the >>#writeBoolean:on: selector but the
generic one, the same applies to the Integer conversion. This
is because instances are of class True, False, SmallInteger,
LarsePositiveInteger, ....

For the Boolean it was easy to add True/False to the lookup
table for integers this is getting hairy.

I did this:

        aValue isNil ifTrue: [ aStream nextPutAll: 'NULL'. ^self ].
        aSelector := converterSelectors at: aValue class
                    ifAbsent: [ aValue isInteger
                                    ifTrue: [#writeInteger:on:]
                                    ifFalse: [#defaultConvert:on:]].

but then again, I could just remove the writeInteger:on:
selector and entry from the look-up table. How should I


reply via email to

[Prev in Thread] Current Thread [Next in Thread]