AndreasSko / go-jwlm

A command line tool to easily merge JW Library backups, written in Go.
MIT License
71 stars 3 forks source link

Skip entries that don't match schema on import #119

Closed AndreasSko closed 2 years ago

AndreasSko commented 2 years ago

For some reason, it's possible that a table contains NULL entries, even if the schema doesn't allow for that. Currently, an import would then fail with a Scan error. As the entry anyway is not valid, we can also simply skip it and continue with the import as usual.

This PR adds a isNullableMismatch function, which can check if a given error is due to a mismatch of a NULL entry and a NOT-NULL schema. If we detect this kind of issue while scanning a table, we don't need to fail, but can simply skip to the next entry.

Fixes #115

coveralls commented 2 years ago

Coverage Status

Coverage decreased (-0.07%) to 86.246% when pulling 3cd5c3f27fa744e2b4d60b6b654fc7a575b6740e on check_schema into 04048866142595033235ea4441da0af334eeba2d on master.