Permalink
Browse files

Don't export data for virtual columns. Fixes #5.

  • Loading branch information...
ansgarbecker committed Nov 8, 2017
1 parent 88bb7eb commit ea522c8c10811aa08f2ffb02790ce43e1a102ae1
Showing with 11 additions and 4 deletions.
  1. +11 −4 source/tabletools.pas
View
@@ -1602,6 +1602,9 @@ procedure TfrmTableTools.DoExport(DBObj: TDBObject);
TargetDbAndObject := Quoter.QuoteIdent(DBObj.Name);
if ToDb then
TargetDbAndObject := Quoter.QuoteIdent(FinalDbName) + '.' + TargetDbAndObject;
// Parse columns, so we can check for special things like virtual columns
ColumnList := TTableColumnList.Create(True);
DBObj.Connection.ParseTableStructure(DBObj.CreateCode, ColumnList, nil, nil);
Offset := 0;
RowCount := 0;
// Calculate limit so we select ~100MB per loop
@@ -1626,8 +1629,10 @@ procedure TfrmTableTools.DoExport(DBObj: TDBObject);
else if comboExportData.Text = DATA_UPDATE then
BaseInsert := 'REPLACE INTO ';
BaseInsert := BaseInsert + TargetDbAndObject + ' (';
for i:=0 to Data.ColumnCount-1 do
BaseInsert := BaseInsert + Quoter.QuoteIdent(Data.ColumnNames[i]) + ', ';
for i:=0 to Data.ColumnCount-1 do begin
if ColumnList[i].Virtuality.IsEmpty then
BaseInsert := BaseInsert + Quoter.QuoteIdent(Data.ColumnNames[i]) + ', ';
end;
Delete(BaseInsert, Length(BaseInsert)-1, 2);
BaseInsert := BaseInsert + ') VALUES'+CRLF+#9+'(';
while true do begin
@@ -1639,6 +1644,8 @@ procedure TfrmTableTools.DoExport(DBObj: TDBObject);
if not IsFirstRowInChunk then
Row := Row + ','+CRLF+#9+'(';
for i:=0 to Data.ColumnCount-1 do begin
if not ColumnList[i].Virtuality.IsEmpty then
Continue;
if Data.IsNull(i) then
Row := Row + 'NULL'
else case Data.DataType(i).Category of
@@ -1657,9 +1664,9 @@ procedure TfrmTableTools.DoExport(DBObj: TDBObject);
end;
else Row := Row + esc(Data.Col(i));
end;
if i<Data.ColumnCount-1 then
Row := Row + ', ';
Row := Row + ', ';
end;
Delete(Row, Length(Row)-1, 2);
Row := Row + ')';
// Break if stream would increase over the barrier of 1MB, and throw away current row
if (not IsFirstRowInChunk)

0 comments on commit ea522c8

Please sign in to comment.