Browse Source

Revert "Cosmetic"

This reverts commit 194ea49d4aa590c9879ead24e279d047f67fa70d.
Reinier Olislagers 11 years ago
parent
commit
f3c8def8ec
2 changed files with 31 additions and 35 deletions
  1. 19 22
      querywindow.pas
  2. 12 13
      tablemanage.pas

+ 19 - 22
querywindow.pas

@@ -180,7 +180,6 @@ type
     fmeResult: TMemo;
     fSQLQuery: TSQLQuery;
     fSQLScript: TSQLScript;
-    // Text for caption
     faText: string;
     fModifyCount: Integer;
     fCnt: Integer;
@@ -209,7 +208,6 @@ type
     OnCommit: TNotifyEvent;
     procedure Init(dbIndex: Integer);
     function GetQueryType(AQuery: string): TQueryTypes;
-    // Get query text from GUI/memo
     function GetQuery: string;
     // Takes existing query or script and uses it to create result tab
     function CreateResultTab(QueryType: TQueryTypes; var aSqlQuery: TSQLQuery; var aSQLScript: TSqlScript;
@@ -313,17 +311,15 @@ var
   i: Integer;
 begin
   for i:= QueryList.Count - 1 downto 0 do
+  if Pos('--', QueryList[i]) > 0 then
   begin
-    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;
+    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;
 
@@ -929,7 +925,7 @@ begin
 end;
 
 
-{ Run current SQL, auto-detect type }
+{ Run current SQL, 0 for auto-detect type }
 procedure TfmQueryWindow.tbRunClick(Sender: TObject);
 begin
   CallExecuteQuery(qtUnknown);
@@ -1045,9 +1041,9 @@ end;
 
 function TfmQueryWindow.GetQuery: string;
 begin
-  Result:= trim(meQuery.SelText);
+  Result:= meQuery.SelText;
   if Result = '' then
-    Result:= trim(meQuery.Lines.Text);
+    Result:= meQuery.Lines.Text;
 end;
 
 
@@ -1336,6 +1332,7 @@ 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);
@@ -1696,7 +1693,7 @@ procedure TfmQueryWindow.FormClose(Sender: TObject;
 begin
   RemoveControls;
 
-  // Check if the transaction is active; then commit it
+  // Check if the transaction is active commit it
   if fSqlTrans.Active then
   begin
     fSqlTrans.CommitRetaining;
@@ -1717,8 +1714,8 @@ begin
   // Initialize new instance of IBConnection and SQLTransaction
   ibConnection:= TIBConnection.Create(nil);
   fSqlTrans:= TSQLTransaction.Create(nil);
-  fSQLQuery:= TSQLQuery.Create(nil);
-  fSQLScript:= TSQLScript.Create(nil);
+  FSQLQuery:= TSQLQuery.Create(nil);
+  FSQLScript:= TSQLScript.Create(nil);
   SynCompletion1.ItemList.CommaText:= 'create,table,Select,From,INTEGER,FLOAT';
   SortSynCompletion;
 end;
@@ -1726,8 +1723,8 @@ end;
 procedure TfmQueryWindow.FormDestroy(Sender: TObject);
 begin
   // Clean up resources to avoid memory leaks
-  fSQLQuery.Free;
-  fSQLScript.Free;
+  FSQLQuery.Free;
+  FSQLScript.Free;
   fSqlTrans.Free;
   IBConnection.Free;
   FList.Free;
@@ -2101,12 +2098,12 @@ begin
 end;
 
 
-{ Execute query according to passed query type }
+{ Execute query according to passed query ype }
 
 procedure TfmQueryWindow.CallExecuteQuery(aQueryType: TQueryTypes);
 begin
   // Get query text from memo
-  fQuery:= GetQuery;
+  fQuery:= Trim(GetQuery);
   fList.Text:= fQuery;
   fStartLine:= 0;
 

+ 12 - 13
tablemanage.pas

@@ -173,19 +173,18 @@ end;
 procedure TfmTableManage.bbDropClick(Sender: TObject);
 begin
   with sgIndices do
-  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;
+  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;
 end;
 
 procedure TfmTableManage.bbDropConstraintClick(Sender: TObject);