mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 09:28:19 +02:00
fcl-db: tests: PostgreSQL stores unquoted identifiers in lower-case which is not compliant with SQL standard.
(and causes some tests fail) Introduce sql server type identifier char case formating function. git-svn-id: trunk@27129 -
This commit is contained in:
parent
9420a5d7a7
commit
02551d7129
@ -64,7 +64,9 @@ type
|
||||
var SQLConnType : TSQLConnType;
|
||||
SQLServerType : TSQLServerType;
|
||||
FieldtypeDefinitions : Array [TFieldType] of String[20];
|
||||
|
||||
|
||||
function IdentifierCase(const s: string): string;
|
||||
|
||||
implementation
|
||||
|
||||
uses StrUtils;
|
||||
@ -137,6 +139,18 @@ const
|
||||
(ssMySQL,ssMySQL,ssMySQL,ssMySQL,ssMySQL,ssMySQL,ssPostgreSQL,ssFirebird,ssUnknown,ssOracle,ssSQLite,ssMSSQL,ssSybase);
|
||||
|
||||
|
||||
function IdentifierCase(const s: string): string;
|
||||
begin
|
||||
// format unquoted identifier name as required by sql servers
|
||||
case SQLServerType of
|
||||
ssPostgreSQL: Result := LowerCase(s); // PostgreSQL stores unquoted identifiers in lowercase (incompatible with the SQL standard)
|
||||
ssInterbase,
|
||||
ssFirebird : Result := UpperCase(s);
|
||||
else
|
||||
Result := s; // mixed case
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TSQLDBConnector }
|
||||
|
||||
procedure TSQLDBConnector.CreateFConnection;
|
||||
|
@ -477,7 +477,7 @@ var
|
||||
i : byte;
|
||||
|
||||
begin
|
||||
if SQLConnType<>postgresql then Ignore('This test does only apply to Postgres, since others don''t support varchars without length given');
|
||||
if SQLServerType<>ssPostgreSQL then Ignore('This test does only apply to Postgres, since others don''t support varchars without length given');
|
||||
|
||||
CreateTableWithFieldType(ftString,'VARCHAR');
|
||||
TestFieldDeclaration(ftString,dsMaxStringSize+1);
|
||||
@ -1341,12 +1341,12 @@ begin
|
||||
with ds do
|
||||
begin
|
||||
AFld1 := TIntegerField.Create(ds);
|
||||
AFld1.FieldName := 'ID';
|
||||
AFld1.FieldName := IdentifierCase('ID');
|
||||
AFld1.DataSet := ds;
|
||||
AFld1.ProviderFlags := AFld1.ProviderFlags + [pfInKey];
|
||||
|
||||
AFld2 := TStringField.Create(ds);
|
||||
AFld2.FieldName := 'NAME';
|
||||
AFld2.FieldName := IdentifierCase('NAME');
|
||||
AFld2.DataSet := ds;
|
||||
|
||||
AFld3 := TIntegerField.Create(ds);
|
||||
@ -1987,8 +1987,8 @@ begin
|
||||
Close;
|
||||
|
||||
// tests parsing SELECT with quoted identifiers (MySQL requires sql-mode=ANSI_QUOTES)
|
||||
SQL.Text:='SELECT"ID"FROM"FPDEV"ORDER BY"ID"';
|
||||
if SQLServerType in [ssPostgreSQL] then SQL.Text:=lowercase(SQL.Text); // The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard
|
||||
// The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard
|
||||
SQL.Text:=IdentifierCase('SELECT"ID"FROM"FPDEV"ORDER BY"ID"');
|
||||
Open;
|
||||
CheckTrue(CanModify, SQL.Text);
|
||||
Close;
|
||||
|
Loading…
Reference in New Issue
Block a user