Skip to content

Better default options and configuration for the CSV import #1395

@MKleusberg

Description

@MKleusberg

@karim came up with a good default behaviour for the CSV import in #1349:

I just want to say something. 😃

Regarding the expected behavior of DB4S when importing empty values from a CSV.

  1. If the column has a default value then it gets priority over everything else.
    • This is the default action for SQLite, it fills columns with default values when a value is not given.
    • The column being NOT NULL or not doesn't matter, since a value will be set for it anyway.
    • ✔️ No need for a checkbox, it should be the right thing to do. 👍
  2. If the column does not have a default value.
    1. Check if the column does not have NOT NULL, if true:
      • Then just add NULL to it, it should be the default.
      • Be consistent. CSV value is NULL, SQLite table doesn't forbid NULL, so just add NULL.
      • ✔️ Also, no need for a checkbox, and this is what everyone here wants. 🎉
    2. Else if it does have NOT NULL, then we have two options, either:
      1. Fail the import (make sense since you are importing NULL to a NOT NULL column), or
      2. Set a default value for it (e.g. 0 for INTEGER, "" for TEXT)
        • Probably by adding a checkbox to "set default values for empty fields in NOT NULL columns" (need a better wording 😄)

We should implement some rules in the import code to reflect this and maybe add some configuration options to make any deviation from this default an explicit decision by the user.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions