Browse Source

Merge pull request #1556 from nocodb/fix/csv-import

fix: csv import logic
pull/1558/head
աɨռɢӄաօռɢ 3 years ago committed by GitHub
parent
commit
63b58b7167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      packages/nc-gui/components/project/spreadsheet/components/importExport/columnMappingModal.vue
  2. 2
      packages/nc-gui/components/project/spreadsheet/components/moreActions.vue

8
packages/nc-gui/components/project/spreadsheet/components/importExport/columnMappingModal.vue

@ -151,6 +151,14 @@ export default {
if ((this.mappings || []).filter(v => v.destCn === _cn).length > 1) { return 'Duplicate mapping found, please remove one of the mapping' }
// check if the input contains null value for a required column
if (v.pk ? !v.ai && !v.cdf : !v.cdf && v.rqd) {
if (this.parsedCsv && this.parsedCsv.data && this.parsedCsv.data.slice(0, 500)
.some(r => r[row.sourceCn] === null || r[row.sourceCn] === undefined || r[row.sourceCn] === "" )) {
return `null value violates not-null constraint`
}
}
switch (v.uidt) {
case UITypes.Number:
if (this.parsedCsv && this.parsedCsv.data && this.parsedCsv.data.slice(0, 500)

2
packages/nc-gui/components/project/spreadsheet/components/moreActions.vue

@ -289,6 +289,8 @@ export default {
} else if (input == 'true' || input == 'yes' || input == 'y') {
input = '1'
}
} else if (v.uidt === UITypes.Number) {
if (input == "") input = null
}
res[col.destCn] = input
}

Loading…
Cancel
Save