File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ TTableColumnList = class(TObjectList<TTableColumn>)
6969 public
7070 procedure Assign (Source: TTableColumnList);
7171 function FindByName (const Value : String): TTableColumn;
72+ function HasInvisibleColumns : Boolean;
73+ function QuoteIdents : String;
7274 end ;
7375 TColumnCache = TDictionary<String,TTableColumnList>;
7476
@@ -10994,6 +10996,31 @@ function TTableColumnList.FindByName(const Value: String): TTableColumn;
1099410996 end ;
1099510997end ;
1099610998
10999+ function TTableColumnList.HasInvisibleColumns : Boolean;
11000+ var
11001+ Col: TTableColumn;
11002+ begin
11003+ Result := False;
11004+ for Col in Self do begin
11005+ if Col.Invisible then begin
11006+ Result := True;
11007+ Break;
11008+ end ;
11009+ end ;
11010+ end ;
11011+
11012+ function TTableColumnList.QuoteIdents : String;
11013+ var
11014+ Col: TTableColumn;
11015+ QuotedNames: TStringList;
11016+ begin
11017+ QuotedNames := TStringList.Create;
11018+ for Col in Self do begin
11019+ QuotedNames.Add(Col.Connection.QuoteIdent(Col.Name ));
11020+ end ;
11021+ Result := Implode(' , ' , QuotedNames);
11022+ QuotedNames.Free;
11023+ end ;
1099711024
1099811025
1099911026{ *** TTableKey }
Original file line number Diff line number Diff line change @@ -1794,7 +1794,7 @@ procedure TfrmTableTools.DoExport(DBObj: TDBObject);
17941794 KeyList: TTableKeyList;
17951795 Column: TTableColumn;
17961796 Quoter: TDBConnection;
1797- TargetFileName, SetCharsetCode: String;
1797+ TargetFileName, SetCharsetCode, ColumnsForSelect : String;
17981798 OrderBy: String;
17991799const
18001800 TempDelim = ' //' ;
@@ -2078,8 +2078,13 @@ procedure TfrmTableTools.DoExport(DBObj: TDBObject);
20782078 TargetDbAndObject := Quoter.QuoteIdent(FinalDbName) + ' .' + TargetDbAndObject;
20792079 Offset := 0 ;
20802080 RowCount := 0 ;
2081- // Sort by primary key if one exists, see issue #2168
2081+ // Examine columns
20822082 ColumnList := DBObj.TableColumns;
2083+ if not ColumnList.HasInvisibleColumns then
2084+ ColumnsForSelect := ' *'
2085+ else
2086+ ColumnsForSelect := ColumnList.QuoteIdents;
2087+ // Sort by primary key if one exists, see issue #2168
20832088 KeyList := DBObj.TableKeys;
20842089 KeyColumns := DBObj.Connection.GetKeyColumns(ColumnList, KeyList);
20852090 OrderBy := ' ' ;
@@ -2102,7 +2107,7 @@ procedure TfrmTableTools.DoExport(DBObj: TDBObject);
21022107 Data := DBObj.Connection.GetResults(
21032108 DBObj.Connection.ApplyLimitClause(
21042109 ' SELECT' ,
2105- ' /* ' +APPNAME+' ' +MainForm.AppVersion+' */ * FROM ' +DBObj.QuotedDbAndTableName + OrderBy,
2110+ ' /* ' +APPNAME+' ' +MainForm.AppVersion+' */ ' + ColumnsForSelect + ' FROM ' +DBObj.QuotedDbAndTableName + OrderBy,
21062111 Limit,
21072112 Offset)
21082113 );
You can’t perform that action at this time.
0 commit comments