From 23f2239ff108db5a0bc69a7465c39afc6734c1c2 Mon Sep 17 00:00:00 2001 From: Adrien Aury <44274230+adrienaury@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:12:51 +0200 Subject: [PATCH] feat: import no (#325) * test(importno): add venom test * test(importno): add venom test * feat(importno): implement feature * feat(importno): fix nil panic --- CHANGELOG.md | 1 + pkg/push/driver.go | 10 +++++++++- tests/suites/push/import.yml | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 182d154d..520bbed0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Types of changes - `Added` possibility to filter columns via `select` property in ingress descriptors - `Added` commands `set-parent-select` and `set-child-select` to `lino id` +- `Added` `import: no` option for columns in `tables.yaml` configuration ## [3.0.2] diff --git a/pkg/push/driver.go b/pkg/push/driver.go index 9f5a1294..96800ee4 100755 --- a/pkg/push/driver.go +++ b/pkg/push/driver.go @@ -175,11 +175,19 @@ func FilterRelation(row Row, relations map[string]Relation, whereField string) ( // pushRow push a row in a specific table func pushRow(row Row, ds DataDestination, table Table, plan Plan, mode Mode, translator Translator, whereField string) *Error { frow, fwhere, frel, fInverseRel, err1 := FilterRelation(row, plan.RelationsFromTable(table), whereField) - if err1 != nil { return err1 } + // remove not imported values from frow + if columns := table.Columns(); columns != nil { + for i := uint(0); i < columns.Len(); i++ { + if columns.Column(i).Import() == "no" { + delete(frow, columns.Column(i).Name()) + } + } + } + rw, err2 := ds.RowWriter(table) if err2 != nil { return err2 diff --git a/tests/suites/push/import.yml b/tests/suites/push/import.yml index 3628f551..4420aa3b 100644 --- a/tests/suites/push/import.yml +++ b/tests/suites/push/import.yml @@ -125,3 +125,25 @@ testcases: - result.code ShouldEqual 0 - result.systemout ShouldBeEmpty - result.systemerr ShouldBeEmpty + + - name: import no + steps: + - script: lino table extract source --only-tables + - script: lino pull source --table customer --limit 0 | lino push truncate dest --table customer + - script: |- + cat > tables.yaml <