mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
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:
@@ -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);
|
||||
|
||||
@@ -275,14 +275,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QCheckBox" name="checkIgnoreDefaults">
|
||||
<property name="toolTip">
|
||||
<string>When importing an empty value from the CSV file into an existing table with a default value for this column, that default value is inserted. Activate this option to insert an empty value instead.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="labelIgnoreDefaults">
|
||||
<property name="text">
|
||||
<string>Ignore default &values</string>
|
||||
@@ -292,14 +292,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="QCheckBox" name="checkFailOnMissing">
|
||||
<property name="toolTip">
|
||||
<string>Activate this option to stop the import when trying to import an empty value into a NOT NULL column without a default value.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="labelFailOnMissing">
|
||||
<property name="text">
|
||||
<string>Fail on missing values </string>
|
||||
@@ -309,6 +309,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelNoTypeDetection">
|
||||
<property name="text">
|
||||
<string>Disable data type detection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="checkNoTypeDetection">
|
||||
<property name="toolTip">
|
||||
<string>Disable the automatic data type detection when creating a new table.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user