Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
When using the tr-TR locale (Turkish in Turkey) ,IBX `ParamByName` throws `EIBClientError with message 'Field "id" not found'` because it uses `ToUpper` inside `FormatIdentifierValue instead of `ToUpperInvariant` so it cannot match 'id' against ':ID' in `lDataSet.SelectSQL.Text`. Fix for Delphi XE8 can be gotten from this diff: https://gist.gith…
unit IBDataSetTestsUnit;
interface
uses
DUnitX.TestFramework;
type
[TestFixture]
TIBDataSetTests = class(TObject)
strict private
procedure Employee_Gdbs_Succeeds(const aLocaleID, aSQLDialect: Integer);
public
[Test]
procedure LocaleId_English_US_Employee_Gdbs_Dialect1_Succeeds;
[Test]
procedure LocaleId_English_US_Employee_Gdbs_Dialect3_Succeeds;
[Test]
procedure LocaleId_Turkish_Turkey_Employee_Gdbs_Dialect1_Succeeds;
[Test]
procedure LocaleId_Turkish_Turkey_Employee_Gdbs_Dialect3_Succeeds;
end;
implementation
uses
IBX.IB,
IBX.IBBatchUpdate,
IBX.IBBlob,
IBX.IBConnectionBroker,
IBX.IBCSMonitor,
// IBX.IBCustomDataSet,
// IBX.IBDatabase,
IBX.IBDatabaseInfo,
IBX.IBDatabaseINI,
IBX.IBErrorCodes,
IBX.IBEvents,
IBX.IBExternals,
IBX.IBExtract,
IBX.IBFilterDialog,
IBX.IBFilterSummary,
IBX.IBHeader,
IBX.IBInstall,
IBX.IBInstallHeader,
IBX.IBIntf,
IBX.IBQuery,
IBX.IBScript,
IBX.IBServices,
IBX.IBSQL,
IBX.IBSQLMonitor,
IBX.IBStoredProc,
IBX.IBSubscription,
IBX.IBTable,
IBX.IBUpdateSQL,
IBX.IBUtils,
IBX.IBVisualConst,
IBX.IBXConst,
IBX.IBXMLHeader,
System.SysUtils,
IBX.IBCustomDataSet,
IBX.IBDatabase,
Winapi.Windows;
procedure TIBDataSetTests.Employee_Gdbs_Succeeds(const aLocaleID, aSQLDialect: Integer);
var
lDatabase: TIBDatabase;
lDataSet: TIBDataSet;
lOriginalLocaleID: Integer;
lTransaction: TIBTransaction;
begin
lOriginalLocaleID := GetThreadLocale;
try
SetThreadLocale(aLocaleID);
GetFormatSettings();
lDatabase := TIBDatabase.Create(nil);
try
lDatabase.ServerType := 'IBServer'; // force to use gds32.dll
lDatabase.DatabaseName := '127.0.0.1:C:\ProgramData\Embarcadero\InterBase\gds_db\examples\database\employee.gdb';
// lDatabase.ServerType := 'IBEmbedded'; // force to use ibtogo.dll
// lDatabase.DatabaseName := 'C:\ProgramData\Embarcadero\InterBase\gds_db\examples\database\employee.gdb';
lDatabase.Params.Clear;
lDatabase.Params.Add('user_name=SYSDBA');
lDatabase.Params.Add('password=masterkey');
lDatabase.LoginPrompt := False;
lDatabase.IdleTimer := 0;
lDatabase.SQLDialect := aSQLDialect;
lDatabase.TraceFlags := [];
lTransaction := TIBTransaction.Create(nil);
try
lTransaction.DefaultDatabase := lDatabase;
lDatabase.Connected := True;
lDataSet := TIBDataSet.Create(nil);
try
lDataSet.Database := lDatabase;
lDataSet.Transaction := lTransaction;
lDataSet.SelectSQL.Text := 'select rdb$relation_id from rdb$database where rdb$relation_id <> :ID';
lDataSet.ParamByName('id').AsInteger := -aSQLDialect;
// when using the tr-TR locale (Turkish in Turkey),
// the above `ParamByName` throws `EIBClientError with message 'Field "id" not found'`
// because it uses `ToUpper` inside `FormatIdentifierValue instead of `ToUpperInvariant`
// so it cannot match 'id' against ':ID' in `lDataSet.SelectSQL.Text`
// Similar issues could potentially happen in other non-invariant locales as well.
finally
lDataSet.Free();
end;
finally
lTransaction.Free();
end;
finally
lDatabase.Free();
end;
finally
SetThreadLocale(lOriginalLocaleID);
GetFormatSettings();
end;
Assert.Pass();
end;
procedure TIBDataSetTests.LocaleId_English_US_Employee_Gdbs_Dialect1_Succeeds;
begin
Employee_Gdbs_Succeeds($0409, 1);
end;
procedure TIBDataSetTests.LocaleId_English_US_Employee_Gdbs_Dialect3_Succeeds;
begin
Employee_Gdbs_Succeeds($0409, 3);
end;
procedure TIBDataSetTests.LocaleId_Turkish_Turkey_Employee_Gdbs_Dialect1_Succeeds;
begin
Employee_Gdbs_Succeeds($041F, 1);
end;
procedure TIBDataSetTests.LocaleId_Turkish_Turkey_Employee_Gdbs_Dialect3_Succeeds;
begin
Employee_Gdbs_Succeeds($041F, 3);
end;
initialization
TDUnitX.RegisterTestFixture(TIBDataSetTests);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.