Skip to content
Permalink
Browse files

Issue #12: fix row count always -1 on SQLite, in "copy table" dialog

  • Loading branch information
ansgarbecker committed Jan 22, 2020
1 parent feeb17e commit 103a61dc52e88e6d95f444925eca105474dab0cc
Showing with 9 additions and 6 deletions.
  1. +2 −2 source/copytable.pas
  2. +6 −3 source/dbconnection.pas
  3. +1 −1 source/main.pas
@@ -255,7 +255,7 @@ procedure TCopyTableForm.TreeElementsGetText(Sender: TBaseVirtualTree; Node: PVi
nColumns: CellText := _('Columns');
nKeys: CellText := _('Indexes');
nForeignKeys: CellText := _('Foreign keys');
nData: CellText := f_('Data (%s rows)', [FormatNumber(FDBObj.Rows)]);
nData: CellText := f_('Data (%s rows)', [FormatNumber(FDBObj.RowCount(False))]);
else raise Exception.Create(_(SUnhandledNodeIndex));
end;
if Node.Index <> nData then begin
@@ -315,7 +315,7 @@ procedure TCopyTableForm.TreeElementsInitNode(Sender: TBaseVirtualTree; ParentNo
end;
if ChildCount > 0 then
Include(InitialStates, ivsHasChildren);
if (ChildCount = 0) or ((Node.Index = nData) and (FDBObj.Rows = 0)) then
if (ChildCount = 0) or ((Node.Index = nData) and (FDBObj.RowCount(False) = 0)) then
Node.States := Node.States + [vsDisabled]
else if AppSettings.ReadBool(Option) then
Node.CheckState := csCheckedNormal;
@@ -142,7 +142,7 @@ TDBObject = class(TPersistent)
function QuotedName(AlwaysQuote: Boolean=True; SeparateSegments: Boolean=True): String;
function QuotedDbAndTableName(AlwaysQuote: Boolean=True): String;
function QuotedColumn(AlwaysQuote: Boolean=True): String;
function RowCount: Int64;
function RowCount(Reload: Boolean): Int64;
function GetCreateCode: String; overload;
function GetCreateCode(RemoveAutoInc, RemoveDefiner: Boolean): String; overload;
property ObjType: String read GetObjType;
@@ -8384,9 +8384,12 @@ function TDBObject.QuotedColumn(AlwaysQuote: Boolean=True): String;
Result := Connection.QuoteIdent(Column, AlwaysQuote);
end;

function TDBObject.RowCount: Int64;
function TDBObject.RowCount(Reload: Boolean): Int64;
begin
Result := Connection.GetRowCount(Self);
if (Rows = -1) or Reload then begin
Rows := Connection.GetRowCount(Self);
end;
Result := Rows;
end;

procedure TDBObject.Drop;
@@ -5455,7 +5455,7 @@ procedure TMainForm.DisplayRowCountStats(Sender: TBaseVirtualTree);
if (not IsLimited) and (not IsFiltered) then
RowsTotal := DataGrid.RootNodeCount // No need to fetch via SHOW TABLE STATUS
else
RowsTotal := DBObject.RowCount;
RowsTotal := DBObject.RowCount(True);
if RowsTotal > -1 then begin
cap := cap + ': ' + FormatNumber(RowsTotal) + ' ' + _('rows total');
if DBObject.Engine = 'InnoDB' then

0 comments on commit 103a61d

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