Developers Manual 1.20

4. Customising ReStore for Individual Databases

4.1 Configuration

The heart of ReStore's configurable database interface is the class SSWSQLDialect. Your SSWReStore instance maintains an instance of this, which it uses as a reference for certain database features. All configuration methods can be foung in the initializing method category of this class.

It is a good idea to familiarise yourself with the format of these methods before proceeding.

Automatic Configuration
To maintain ease-of-use, ReStore is able to automatically configure itself to your chosen database on connecting. This behaviour is coordinated through the SSWSQLDialect method autoInitializeIn:

autoInitializeIn: anSSWReStore

    "Automatically configure the receiver for the active DB type, if known"

    | dbmsName dbmsVer |

    self initializeStandard.

    dbmsName := (anSSWReStore connection getInfoString: SQLDBMSName) asUppercase.
    dbmsVer := anSSWReStore connection getInfoString: SQLDBMSVer.
    dbmsName = 'ACCESS' ifTrue: [self modifyForAccess].
    dbmsName = 'MYSQL' ifTrue: [self modifyForMySQL]

As can be seen, this method first applies the 'standard' configuration. It then attempts to refine this with a modification method by comparing known database names against the value held in dbmsName. This is the value returned from the ODBC function


The value of this function may be detailed in your database's documentation, but for absolute certainty a breakpoint (halt) can be placed in this method prior to connecting to the database. The actual String returned by the database may then be inspected.

Once you have determined the String returned by your database, you will then need to modify this method to call a suitable configuration method, as is done with Access and MySQL. e.g.

dbmsName = 'DATABASE X' ifTrue: [self modifyForDatabaseX]

The remainder of this chapter details the implementation of the configuration method itself.


Handling Different Versions
autoConfigureIn: also makes available the result of the ODBC function 

GetInfoString(SQL_DBMS_VER) the temporary variable dbmsVer - this denotes which version of your chosen database you are using. If you intend to use different versions of your database you may additionally need to take account of this value when deciding on a configuration method, in order to handle differences between versions. e.g.

dbmsName = 'DATABASE X' ifTrue: 
    [('1.*' match: dbmsVer) ifTrue: [self modifyForDatabaseXVersion1].
    ('2.*' match: dbmsVer) ifTrue: [self modifyForDatabaseXVersion2]].


4. Customising ReStore for Individual Databases

2000-2003 Solutions Software Ltd.

Home | Index | Next