Glorp with PostgresV2 on Pharo 4

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

Glorp with PostgresV2 on Pharo 4

Pierce Ng-3
I'm on a roll. :-) I've written another blog post on installing Glorp with
PostgresV2 on Pharo 4.

To avoid this message looking like spam mail promoting my blog and devoid of
content, here's the slightly edited blog post, in its original Markdown format
sans JSON metadata.

Outside of Smalltalk, create the database 'sodbxtest', user 'sodbxtest'
with password 'sodbxtest':

    # su postgres -c psql
    postgres=# create role sodbxtest with password 'sodbxtest' login;
    CREATE ROLE
    postgres=# create database sodbxtest;
    CREATE DATABASE
    postgres=# \q
    #

In Smalltalk, firstly, install PostgresV2:

    Gofer it
        smalltalkhubUser: 'PharoExtras'
        project: 'PostgresV2';
        package: 'ConfigurationOfPostgresV2';
        load.
    ((Smalltalk at: #ConfigurationOfPostgresV2) project version: '2.4') load.

Open Test Runner and runs the PostgresV2 tests. On my Linux Mint machine,
using a vanilla PostgreSQL 9.3 installation, 23 of 24 tests passed, and
TestPGConnection>>#testNotify2 erred.

Now that we know the PostgresV2 driver can talk to our database, using the
Monticello browser, open the PostgresV2 repository and load the package
GlorpDriverPostgreSQL. Here I had to edit
NativePostgresDriver>>connectionArgsFromCurrentLogin: to comment out
the second last line:

        connectionArgs clientEncoding: aLogin encodingStrategy asSymbol

This is because GlorpDatabaseLoginResource class>defaultPostgreSQLLocalLogin
does not specify encodingStrategy, meaning it is nil and will respond
to #asSymbol with DNU.

Next, in a playground, execute the following:

    GlorpDemoTablePopulatorResource invalidateSetup.
    GlorpDatabaseLoginResource
        defaultLogin: GlorpDatabaseLoginResource defaultPostgreSQLLocalLogin

Open Test Runner and run the Glorp tests.

Tested on Linux Mint 17.



Reply | Threaded
Open this post in threaded view
|

Re: Glorp with PostgresV2 on Pharo 4

Sven Van Caekenberghe-2

> On 03 Apr 2015, at 06:58, Pierce Ng <[hidden email]> wrote:
>
> Now that we know the PostgresV2 driver can talk to our database, using the
> Monticello browser, open the PostgresV2 repository and load the package
> GlorpDriverPostgreSQL. Here I had to edit
> NativePostgresDriver>>connectionArgsFromCurrentLogin: to comment out
> the second last line:
>
>        connectionArgs clientEncoding: aLogin encodingStrategy asSymbol
>
> This is because GlorpDatabaseLoginResource class>defaultPostgreSQLLocalLogin
> does not specify encodingStrategy, meaning it is nil and will respond
> to #asSymbol with DNU.

Yes, we have to fix that, but you also set it manually, no real need to patch the code:

createLogin
  ^ Login new
      database: PostgreSQLPlatform new;
      username: 'sven';
      password: '';
      connectString: 'localhost:5432_sven';
      encodingStrategy: #utf8;
      yourself

Interesting articles !

Sven


Reply | Threaded
Open this post in threaded view
|

Re: Glorp with PostgresV2 on Pharo 4

Pierce Ng-3
On Fri, Apr 03, 2015 at 07:20:40AM +0200, Sven Van Caekenberghe wrote:
> Yes, we have to fix that, but you also set it manually, no real need to patch
> the code:

Ok, wasn't sure what the encoding strategy should be. I'll patch
GlorpDatabaseLoginResource then.

Pierce