Skip to content

Commit

Permalink
feat: import no (#325)
Browse files Browse the repository at this point in the history
* test(importno): add venom test

* test(importno): add venom test

* feat(importno): implement feature

* feat(importno): fix nil panic
  • Loading branch information
adrienaury authored Oct 21, 2024
1 parent 859bb18 commit 23f2239
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
10 changes: 9 additions & 1 deletion pkg/push/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions tests/suites/push/import.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
version: v1
tables:
- name: customer
keys:
- customer_id
columns:
- name: "customer_id"
import: "no"
- name: "first_name"
EOF
- script: lino pull source --table customer --filter customer_id=1 | lino push update dest --table customer -vdebug
assertions:
- result.systemerr ShouldContainSubstring UPDATE customer SET first_name=$1 WHERE customer_id=$2
- result.code ShouldEqual 0
- result.systemout ShouldBeEmpty

0 comments on commit 23f2239

Please sign in to comment.