Add option to disable automatic type detection in CSV import

Because there are some circumstances under which the automatic type
detection can cause problems with the imported data and because it is
not accurate when the data changes a lot after the first couple of rows,
we need an option to disable it.

See issue #1382.
This commit is contained in:
Martin Kleusberg
2018-05-25 22:11:43 +02:00
parent e851c161d6
commit 3995ad2442
2 changed files with 22 additions and 6 deletions

View File

@@ -415,8 +415,8 @@ sqlb::FieldVector ImportCsvDialog::generateFieldList(const QString& filename)
fieldList.push_back(sqlb::FieldPtr(new sqlb::Field(fieldname, "")));
}
// Try to find out a data type for each column
if(!(rowNum == 0 && ui->checkboxHeader->isChecked()))
// Try to find out a data type for each column. Skip the header row if there is one.
if(!ui->checkNoTypeDetection->isChecked() && !(rowNum == 0 && ui->checkboxHeader->isChecked()))
{
for(size_t i=0;i<data.num_fields;i++)
{
@@ -774,6 +774,8 @@ QString ImportCsvDialog::currentEncoding() const
void ImportCsvDialog::toggleAdvancedSection(bool show)
{
ui->labelNoTypeDetection->setVisible(show);
ui->checkNoTypeDetection->setVisible(show);
ui->labelFailOnMissing->setVisible(show);
ui->checkFailOnMissing->setVisible(show);
ui->labelIgnoreDefaults->setVisible(show);