Put full cell data into INSERT statements when dragging tables

In the Structure tab you can drag & drop entire tables. This copies the
CREATE statement of the table along with the INSERT statements for the
table data. However, for the table data we would use the data as shown
in the table view cells, i.e. 'NULL' for NULL values or truncated data
for very long strings. This is at least partly improved by this commit.
It doesn't treat NULL or BLOB values 100% correctly but fixes the
truncation problem and at least makes the issues in the other cases a
bit more obvious.
This commit is contained in:
Martin Kleusberg
2018-01-01 20:11:26 +01:00
parent 106e57eedc
commit 117af5aeeb

View File

@@ -222,7 +222,7 @@ QMimeData* DbStructureModel::mimeData(const QModelIndexList& indices) const
{
QString insertStatement = "INSERT INTO " + objid.toString() + " VALUES(";
for(int j=1; j < tableModel.columnCount(); ++j)
insertStatement += QString("'%1',").arg(tableModel.data(tableModel.index(i, j)).toString());
insertStatement += QString("'%1',").arg(tableModel.data(tableModel.index(i, j), Qt::EditRole).toString());
insertStatement.chop(1);
insertStatement += ");\n";
sqlData.append(insertStatement);