Reinier Olislagers 11 anos atrás
pai
commit
de9de85f7f
2 arquivos alterados com 31 adições e 27 exclusões
  1. 18 15
      querywindow.pas
  2. 13 12
      tablemanage.pas

+ 18 - 15
querywindow.pas

@@ -180,6 +180,7 @@ type
     fmeResult: TMemo;
     fSqlQuery: TSQLQuery;
     fSqlScript: TSQLScript;
+    // Text for caption
     faText: string;
     fModifyCount: Integer;
     fCnt: Integer;
@@ -208,6 +209,7 @@ type
     OnCommit: TNotifyEvent;
     procedure Init(dbIndex: Integer);
     function GetQueryType(AQuery: string): TQueryTypes;
+    // Get query text from GUI/memo
     function GetQuery: string;
     function CreateResultTab(QueryType: TQueryTypes; var aSqlQuery: TSQLQuery; var aSQLScript: TSqlScript;
       var meResult: TMemo; AdditionalTitle: string = ''): TTabSheet;
@@ -310,15 +312,17 @@ var
   i: Integer;
 begin
   for i:= QueryList.Count - 1 downto 0 do
-  if Pos('--', QueryList[i]) > 0 then
   begin
-    if Pos('--', Trim(QueryList[i])) = 1 then
-      QueryList.Delete(i);
-    {
-    else
-      //todo: this will also pick up -- within string literals which is wrong
-      QueryList[i]:= Copy(QueryList[i], 1, Pos('--', QueryList[i]) - 1);
-    }
+    if Pos('--', QueryList[i]) > 0 then
+    begin
+      if Pos('--', Trim(QueryList[i])) = 1 then
+        QueryList.Delete(i);
+      {
+      else
+        //todo: this will also pick up -- within string literals which is wrong
+        QueryList[i]:= Copy(QueryList[i], 1, Pos('--', QueryList[i]) - 1);
+      }
+    end;
   end;
 end;
 
@@ -919,7 +923,7 @@ begin
 end;
 
 
-{ Run current SQL, 0 for auto-detect type }
+{ Run current SQL, auto-detect type }
 procedure TfmQueryWindow.tbRunClick(Sender: TObject);
 begin
   CallExecuteQuery(qtUnknown);
@@ -1035,9 +1039,9 @@ end;
 
 function TfmQueryWindow.GetQuery: string;
 begin
-  Result:= meQuery.SelText;
+  Result:= trim(meQuery.SelText);
   if Result = '' then
-    Result:= meQuery.Lines.Text;
+    Result:= trim(meQuery.Lines.Text);
 end;
 
 
@@ -1325,7 +1329,6 @@ begin
               fmeResult.Lines.Add(FormatDateTime('hh:nn:ss.z', Now) + ' - DML Executed. Takes (H:M:S.MS) ' +
                 FormatDateTime('HH:nn:ss.z', Now - StartTime));
               fmeResult.Lines.Add('Rows affected: ' + Format('%3.0n', [Affected / 1]));
-
             end;
             fmeResult.Lines.Add('----');
             fmeResult.Lines.Add(fQueryPart);
@@ -1684,7 +1687,7 @@ procedure TfmQueryWindow.FormClose(Sender: TObject;
 begin
   RemoveControls;
 
-  // Check if the transaction is active commit it
+  // Check if the transaction is active; then commit it
   if fSqlTrans.Active then
   begin
     fSqlTrans.CommitRetaining;
@@ -2085,12 +2088,12 @@ begin
 end;
 
 
-{ Execute query according to passed query ype }
+{ Execute query according to passed query type }
 
 procedure TfmQueryWindow.CallExecuteQuery(aQueryType: TQueryTypes);
 begin
   // Get query text from memo
-  fQuery:= Trim(GetQuery);
+  fQuery:= GetQuery;
   fList.Text:= fQuery;
   fStartLine:= 0;
 

+ 13 - 12
tablemanage.pas

@@ -173,18 +173,19 @@ end;
 procedure TfmTableManage.bbDropClick(Sender: TObject);
 begin
   with sgIndices do
-  if RowCount > 1 then
-    if MessageDlg('Are you sure you want to drop index: ' + Cells[0, Row], mtConfirmation,
-      [mbYes, mbNo], 0) = mrYes then
-      begin
-        if Cells[0, Row] = PKeyName then // Delete primary key
-          fmMain.ShowCompleteQueryWindow(fdbIndex,  'Drop Primary Key on Table: ' + fTableName,
-            'alter table ' + fTableName + ' DROP constraint ' + ConstraintName, bbRefreshIndices.OnClick)
-        else // Delete secondary key
-          fmMain.ShowCompleteQueryWindow(fdbIndex, 'Drop Secondary Index on table: ' + fTableName,
-            'DROP INDEX ' + Cells[0, Row], bbRefreshIndices.OnClick);
-
-      end;
+  begin
+    if (RowCount > 1) and
+      (MessageDlg('Are you sure you want to drop index: ' + Cells[0, Row], mtConfirmation,
+        [mbYes, mbNo], 0) = mrYes) then
+    begin
+      if Cells[0, Row] = PKeyName then // Delete primary key
+        fmMain.ShowCompleteQueryWindow(fdbIndex,  'Drop Primary Key on Table: ' + fTableName,
+          'alter table ' + fTableName + ' DROP constraint ' + ConstraintName, bbRefreshIndices.OnClick)
+      else // Delete secondary key
+        fmMain.ShowCompleteQueryWindow(fdbIndex, 'Drop Secondary Index on table: ' + fTableName,
+          'DROP INDEX ' + Cells[0, Row], bbRefreshIndices.OnClick);
+    end;
+  end;
 end;
 
 procedure TfmTableManage.bbDropConstraintClick(Sender: TObject);