Setting a charset for non-UTF Oracle DB request/response

When Dreamfactory is configured to use an Oracle DB connection, where the DB is configured with a non-UTF charset, problems might arise. Some of such problems on my configuration were Eastern Europe characters converted to flat ASCII characters (with ‘$charset = null;’) or a blank response / No content response (with ‘$charset = some_wrong_charset;’)

In my case, the DB itself was configured to use EE8MSWIN1250, so I needed to use a matching charset in Dreamfactory.

Setting a proper charset in DreamFactory 1.9.4-3 on Linux (I didn’t test it on Windows, but assume it should also work) can be done by editing \dreamfactory-1.9.4-3\apps\dreamfactory\htdocs\vendor\dreamfactory\yii\framework\db\schema\oci\COciPdoAdapter.php.

Specifically, it looks like this on my configuration:
public function __construct( $dsn, $username, $password, $options )
{
$persistent = false;
$db = substr( $dsn, strpos( $dsn, ‘dbname=’ ) + 7 );
// $charset = null; —> factory setting
$charset = ‘AL32UTF8’; —> working custom setting

}

I have to point out that this example, generated via Dreamfactory GUI in Services section, didn’t work when the ‘;charset=AL32UTF8’ part was added):
‘oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myOracleHost.com)(PORT=1526))(CONNECT_DATA=(SERVICE_NAME=myService.intern)));charset=AL32UTF8;

If Dreamfactory is configured to connect to more than one Oracle DB, which differ in used charsets / language environments, ‘if’ blocks combined with the ‘$charset=…’ expression may be used to match a specific ‘$charset’ with a specific ‘$dsn’ parameter.

Kind folks at Dreamfactory, Jeffrey Stables and Drew Pearce, have significantly contributed to my efforts in finding this solution. Thank you guys!

Regards,
Matija

1 Like