Use different sets of characters not requiring quotes, per connection type. Use that to force quotes around columns with uppercase characters in PostgreSQL. Closes #1072.

This commit is contained in:
Ansgar Becker
2020-06-27 16:10:30 +02:00
parent b4926f3f57
commit ea68cddb24
2 changed files with 6 additions and 4 deletions

View File

@@ -115,7 +115,4 @@ const
HELPERNODE_PROFILE = 5;
HELPERNODE_BINDING = 6;
// A set of characters which need not to be quoted
IDENTCHARS = ['A'..'Z', 'a'..'z', '0'..'9', '_'];

View File

@@ -390,6 +390,7 @@ type
FPrefetchResults: TDBQueryList;
FForeignKeyQueriesFailed: Boolean;
FInfSch: String;
FIdentCharsNoQuote: TSysCharSet;
procedure SetActive(Value: Boolean); virtual; abstract;
procedure DoBeforeConnect; virtual;
procedure DoAfterConnect; virtual;
@@ -1761,6 +1762,8 @@ begin
FForeignKeyQueriesFailed := False;
// System database/schema, should be uppercase on MSSQL only, see #855
FInfSch := 'information_schema';
// Characters in identifiers which don't need to be quoted
FIdentCharsNoQuote := ['A'..'Z', 'a'..'z', '0'..'9', '_'];
end;
@@ -1806,6 +1809,8 @@ begin
FDatatypes[i] := PostGreSQLDatatypes[i];
// cache for 123::regclass queries:
FRegClasses := TOidStringPairs.Create;
// Identifiers with uppercase characters must be quoted, see #1072
FIdentCharsNoQuote := ['a'..'z', '0'..'9', '_'];
end;
@@ -4351,7 +4356,7 @@ begin
if MySQLKeywords.IndexOf(Result) > -1 then
AlwaysQuote := True
else for i:=1 to Length(Result) do begin
if not CharInSet(Result[i], IDENTCHARS) then begin
if not CharInSet(Result[i], FIdentCharsNoQuote) then begin
AlwaysQuote := True;
break;
end;