From 17f9730b764c669018bd7e40e50014f789a19f39 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 16 Oct 2007 19:34:25 +0000 Subject: [PATCH] Fix bugs #1814411 "Incorrect SQL when changing structure on a field" #1814293 "Incorrect SQL when changing structure on a FLOAT field" --- source/fieldeditor.pas | 4 +--- source/helpers.pas | 11 ++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/fieldeditor.pas b/source/fieldeditor.pas index c9cda8e5..fd51f6bb 100644 --- a/source/fieldeditor.pas +++ b/source/fieldeditor.pas @@ -192,9 +192,7 @@ begin EditComment.Text := NodeData.Captions[5]; // extract field type - strtype := UpperCase( NodeData.Captions[1] ); - if Pos ('(',strtype) > 0 then - strtype := Trim(copy (strtype,0,Pos ('(',strtype)-1)); + strtype := UpperCase( getFirstWord( NodeData.Captions[1] ) ); // field field type structure for i := Low(MySqlDataTypeArray) to High(MySqlDataTypeArray) do diff --git a/source/helpers.pas b/source/helpers.pas index 8364adbc..16a4bdcc 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -288,9 +288,14 @@ var p1,p2 : Integer; begin p1 := pos('(', str); - if p1 = 0 then p2 := Length(str) + 1 - else for p2:=strlen(pchar(str)) downto 0 do if str[p2] = ')' then break; - result := copy (str, p1+1, p2-p1-1); + Result := ''; + // Only return something if opening bracket was found, otherwise empty string + if p1 > 0 then + begin + for p2:=strlen(pchar(str)) downto 0 do + if str[p2] = ')' then break; + result := copy (str, p1+1, p2-p1-1); + end; end;