From 28634e67b3bd40e12893946717d4ce2d0c1bac3e Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 31 Mar 2008 17:57:04 +0000 Subject: [PATCH] Follow up to rev 1307: Also analyse table names in JOIN clauses for proposal pulldown. Example: SELECT * FROM tab1 t1 LEFT JOIN tab2 AS t2 WHERE t2.[PULLDOWN!] --- source/childwin.pas | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/childwin.pas b/source/childwin.pas index 21f3abd0..245c0ce3 100644 --- a/source/childwin.pas +++ b/source/childwin.pas @@ -3124,7 +3124,7 @@ procedure TMDIChild.SynCompletionProposal1Execute(Kind: SynCompletionType; var i,j : Integer; tn, child : TTreeNode; - sql : String; + sql, TableClauses: String; Tables : TStringList; tablename : String; rx : TRegExpr; @@ -3189,11 +3189,14 @@ begin rx.ModifierI := True; rx.Expression := '\b(FROM|INTO|UPDATE)\s+(.+)(WHERE|HAVING|ORDER|GROUP)?'; if rx.Exec(sql) then begin - Tables := TStringList.Create; + TableClauses := rx.Match[2]; + // Ensure tables in JOIN clause(s) are splitted by comma + TableClauses := StringReplace(TableClauses, 'JOIN', ',', [rfReplaceAll, rfIgnoreCase]); // Split table clauses by commas + Tables := TStringList.Create; Tables.Delimiter := ','; Tables.StrictDelimiter := true; - Tables.DelimitedText := rx.Match[2]; + Tables.DelimitedText := TableClauses; rx.Expression := '([^\s]+)(\s+(AS\s+)?([^\s]+))?'; for i := 0 to Tables.Count - 1 do begin // If the just typed word equals the alias of this table or the