Glorp Login>>#encodingStrategy

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

Glorp Login>>#encodingStrategy

Sven Van Caekenberghe-2
It seems that Glorp Login>>#encodingStrategy is not used by the NativePostgresDriver yet it is required to set it to a non nil value to get things working. This feels like a hack or something unfinished.

Sven
Reply | Threaded
Open this post in threaded view
|

Re: Glorp Login>>#encodingStrategy

Esteban A. Maringolo
2014-08-27 12:38 GMT-03:00 Sven Van Caekenberghe <[hidden email]>:
> It seems that Glorp Login>>#encodingStrategy is not used by the NativePostgresDriver yet it is required to set it to a non nil value to get things working. This feels like a hack or something unfinished.

How so?

PGConnection>>#clientEncoding: sets instance variables
sqlStringConverter and receivingTextConverter, which are used to
convert text back and forth from Pharo to the socket (see
PGConnection>>#execute:)

It is really convoluted, but I guess this has to do with the pass of
time, and also with the half-backed (IMO) driver independence and
dialect compatibility.

Regards!

Esteban A. Maringolo

Reply | Threaded
Open this post in threaded view
|

Re: Glorp Login>>#encodingStrategy

Sven Van Caekenberghe-2

On 27 Aug 2014, at 18:20, Esteban A. Maringolo <[hidden email]> wrote:

> 2014-08-27 12:38 GMT-03:00 Sven Van Caekenberghe <[hidden email]>:
>> It seems that Glorp Login>>#encodingStrategy is not used by the NativePostgresDriver yet it is required to set it to a non nil value to get things working. This feels like a hack or something unfinished.
>
> How so?
>
> PGConnection>>#clientEncoding: sets instance variables
> sqlStringConverter and receivingTextConverter, which are used to
> convert text back and forth from Pharo to the socket (see
> PGConnection>>#execute:)
>
> It is really convoluted, but I guess this has to do with the pass of
> time, and also with the half-backed (IMO) driver independence and
> dialect compatibility.
>
> Regards!
>
> Esteban A. Maringolo

Thanks for your answer.

I was confused by the name change between encodingStrategy and clientEncoding. You are right it is used. But my point remains that unless you set encodingStrategy on Login to something you get an error when nil in converted to a Symbol (in #connectionArgsFromCurrentLogin:). Now, I set it to #default which does not exist as encoding and leads to no encoding at all. That seems to indicate that it is not needed, but I am not sure.

Sven

The before last line of #connectionArgsFromCurrentLogin: could be changed to

aLogin encodingStrategy ifNotNil: [ :enc | connectionArgs clientEncoding: enc asSymbol ].



Reply | Threaded
Open this post in threaded view
|

Re: Glorp Login>>#encodingStrategy

Sven Van Caekenberghe-2
OK, it seems that setting the encoding to #utf8 is needed when talking to a PG DB that has UTF8 encoding as well for non ASCII to work. Good.

On 28 Aug 2014, at 23:57, Sven Van Caekenberghe <[hidden email]> wrote:

>
> On 27 Aug 2014, at 18:20, Esteban A. Maringolo <[hidden email]> wrote:
>
>> 2014-08-27 12:38 GMT-03:00 Sven Van Caekenberghe <[hidden email]>:
>>> It seems that Glorp Login>>#encodingStrategy is not used by the NativePostgresDriver yet it is required to set it to a non nil value to get things working. This feels like a hack or something unfinished.
>>
>> How so?
>>
>> PGConnection>>#clientEncoding: sets instance variables
>> sqlStringConverter and receivingTextConverter, which are used to
>> convert text back and forth from Pharo to the socket (see
>> PGConnection>>#execute:)
>>
>> It is really convoluted, but I guess this has to do with the pass of
>> time, and also with the half-backed (IMO) driver independence and
>> dialect compatibility.
>>
>> Regards!
>>
>> Esteban A. Maringolo
>
> Thanks for your answer.
>
> I was confused by the name change between encodingStrategy and clientEncoding. You are right it is used. But my point remains that unless you set encodingStrategy on Login to something you get an error when nil in converted to a Symbol (in #connectionArgsFromCurrentLogin:). Now, I set it to #default which does not exist as encoding and leads to no encoding at all. That seems to indicate that it is not needed, but I am not sure.
>
> Sven
>
> The before last line of #connectionArgsFromCurrentLogin: could be changed to
>
> aLogin encodingStrategy ifNotNil: [ :enc | connectionArgs clientEncoding: enc asSymbol ].
>
>