DBI FieldConverter and what to throw away

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DBI FieldConverter and what to throw away

Holger Freyther
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.

e.g.

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
proceed?

holger

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: DBI FieldConverter and what to throw away

Paolo Bonzini-2
Il 20/05/2013 08:55, Holger Hans Peter Freyther ha scritto:

>
>         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
> proceed?

You can leave the Integer entry in the table, but commented out.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk