Skip to content
Permalink
Browse files

Issue #637: No need to upper-case when calling StartsWith() with igno…

…re case flag. Also, prefer StartsWith() over various ugly calls to UpperCase(Copy()).
  • Loading branch information...
ansgarbecker committed May 6, 2019
1 parent 54c6d91 commit 2f77c9ea8c77062242297e312c2c58e20a3ae8f5
Showing with 7 additions and 7 deletions.
  1. +7 −7 source/dbconnection.pas
@@ -5131,15 +5131,15 @@ procedure TDBConnection.ParseTableStructure(CreateTable: String; Columns: TTable
ColSpec := Trim(ColSpec);

// Unsigned
if UpperCase(Copy(ColSpec, 1, 8)) = 'UNSIGNED' then begin
if ColSpec.StartsWith('UNSIGNED', True) then begin
Col.Unsigned := True;
Delete(ColSpec, 1, 8);
ColSpec := Trim(ColSpec);
end else
Col.Unsigned := False;

// Zero fill
if UpperCase(Copy(ColSpec, 1, 8)) = 'ZEROFILL' then begin
if ColSpec.StartsWith('ZEROFILL', True) then begin
Col.ZeroFill := True;
Delete(ColSpec, 1, 8);
ColSpec := Trim(ColSpec);
@@ -5184,13 +5184,13 @@ procedure TDBConnection.ParseTableStructure(CreateTable: String; Columns: TTable
end;

// Allow NULL
if UpperCase(Copy(ColSpec, 1, 8)) = 'NOT NULL' then begin
if ColSpec.StartsWith('NOT NULL', True) then begin
Col.AllowNull := False;
Delete(ColSpec, 1, 8);
end else begin
Col.AllowNull := True;
// Sporadically there is a "NULL" found at this position.
if UpperCase(Copy(ColSpec, 1, 4)) = 'NULL' then
if ColSpec.StartsWith('NULL', True) then
Delete(ColSpec, 1, 4);
end;
ColSpec := Trim(ColSpec);
@@ -5201,11 +5201,11 @@ procedure TDBConnection.ParseTableStructure(CreateTable: String; Columns: TTable
Col.DefaultText := '';
Col.OnUpdateType := cdtNothing;
Col.OnUpdateText := '';
if UpperCase(Copy(ColSpec, 1, 14)) = 'AUTO_INCREMENT' then begin
if ColSpec.StartsWith('AUTO_INCREMENT', True) then begin
Col.DefaultType := cdtAutoInc;
Col.DefaultText := 'AUTO_INCREMENT';
Delete(ColSpec, 1, 15);
end else if UpperCase(Copy(ColSpec, 1, 8)) = 'DEFAULT ' then begin
end else if ColSpec.StartsWith('DEFAULT ', True) then begin
Delete(ColSpec, 1, 8);
ColSpec := Trim(ColSpec);

@@ -5228,7 +5228,7 @@ procedure TDBConnection.ParseTableStructure(CreateTable: String; Columns: TTable
ColSpec := Trim(ColSpec);

// Do the same for a potentially existing ON UPDATE clause
if ColSpec.ToUpper.StartsWith('ON UPDATE ', True) then begin
if ColSpec.StartsWith('ON UPDATE ', True) then begin
Delete(ColSpec, 1, 10);
ColSpec := Trim(ColSpec);
rxCol.Expression := '($|\s+(COLUMN_FORMAT|COMMENT|INVISIBLE)\b)';

0 comments on commit 2f77c9e

Please sign in to comment.
You can’t perform that action at this time.