Hi Wagner,
We have a requirement to deliver out application supporting Arabic. We use both Firebird and MS SQL and connect via Firedac. What changes are recommended to Aurelius to support this. It looks like what we need to do is:
TMS Aurelius
- change our TAureliusDataset
TStringField
to beTWideStringField
- change our entities' memo blob attribute from
[DBTypeMemo]
to[DBTypeWideMemo]
- leave our entities' string fields as
String
notWideString
- for MS SQL set Global Config setting MapStringToNationalChar to true
- for Firebird configure the SQL generator's WideStringCharSet to UTF8
FireDac FDConnectionDef
- Add
CharacterSet=UTF8
to the Firebird connection def
Code Example
Here we are checking how FireDac is configured and configuring Aurelius accordingly
procedure TConnectionFireDac.ConfigureDatabase;
var
ConnectionName: string;
begin
if FindCmdLineSwitch( sConnectionName, ConnectionName, True ) then
conGenWS.ConnectionDefName := ConnectionName;
if SameText( 'MSSQL', conGenWS.ActualDriverID ) then
begin
{See https://support.tmssoftware.com/t/utf8-charset/7411}
TGlobalConfigs.GetInstance.MapStringToNationalChar := True;
conAurelius.SQLDialect := 'MSSQL';
end
else if SameText( 'FB', conGenWS.ActualDriverID ) then
begin
var
Firebird3SQLGenerator := ( TSQLGeneratorRegister.GetInstance.GetGenerator( 'Firebird3' ) as TFirebird3SQLGenerator );
Firebird3SQLGenerator.UseBoolean := False;
Firebird3SQLGenerator.UseIdentity := True;
Firebird3SQLGenerator.WideStringCharSet := 'UTF8';
conAurelius.SQLDialect := 'Firebird3';
end
else
raise Exception.CreateFmt( 'Unsupported database type %s', [ conGenWS.ActualDriverID ] );
end;
In particular we are not certain if we should change our String fields to WideString in our entities. In testing, we have found that the DatabaseManager will only flag Firebird's varchar fields as UTF8 if we change the entity field to be a WideString. However changing the FireDac connection def to be UTF8 gets around that and treats all strings as UTF8. For MSSQL we need the MapStringToNationalChar flag for the fields to be created as NVarChar.
All this appears to work as expected for us. The only fly in the ointment is that we have to manually change the aurelius datasets' field defs as the ones generated by the Aurelius BPL compiled from our entities always generates TStringField and not TWideStringField for our TAureliusDatasets.
Kind Regards
Steve