ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/IBUtils.pas
(Generate patch)

Comparing ibx/trunk/fbintf/IBUtils.pas (file contents):
Revision 106 by tony, Mon Mar 6 10:20:02 2017 UTC vs.
Revision 107 by tony, Thu Jan 18 14:37:40 2018 UTC

# Line 266 | Line 266 | function QuoteIdentifier(Dialect: Intege
266   function QuoteIdentifierIfNeeded(Dialect: Integer; Value: AnsiString): AnsiString;
267   function Space2Underscore(s: AnsiString): AnsiString;
268   function SQLSafeString(const s: AnsiString): AnsiString;
269 + function IsSQLIdentifier(Value: AnsiString): boolean;
270  
271   implementation
272  
# Line 399 | Line 400 | begin
400    Result := Value;
401   end;
402  
403 + const
404 +  ValidSQLIdentifierChars = ['A'..'Z','a'..'z','0'..'9','_','$'];
405 +
406 + function IsSQLIdentifier(Value: AnsiString): boolean;
407 + var i: integer;
408 + begin
409 +  Result := false;
410 +  for i := 1 to Length(Value) do
411 +    if not (Value[i] in ValidSQLIdentifierChars) then Exit;
412 +  Result := true;
413 + end;
414 +
415   function QuoteIdentifierIfNeeded(Dialect: Integer; Value: AnsiString): AnsiString;
416   begin
417    if (Dialect = 3) and
418 <    ((AnsiUpperCase(Value) <> Value) or IsReservedWord(Value)) then
418 >    (IsReservedWord(Value) or not IsSQLIdentifier(Value)) then
419       Result := '"' + Value + '"'
420    else
421      Result := Value

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines