Skip to content

Commit

Permalink
feat(presence): implement flag in row export
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienaury committed Nov 6, 2024
1 parent 74e7ef9 commit c664c98
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/pull/model_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func (t *Table) initTemplate() {
t.template.WithTimestamp(key)
case "no":
t.template.WithHidden(key)
case "presence":
t.template.WithBoolean(key)
default:
t.template.WithAuto(key)
}
Expand Down Expand Up @@ -80,7 +82,7 @@ func (t *Table) export(row Row) ExportedRow {
switch t.ExportMode {
case ExportModeAll:
for k := range row {
if result.GetOrNil(k) == nil {
if _, present := result.Get(k); !present {
keys = append(keys, k)
}
}
Expand All @@ -93,6 +95,17 @@ func (t *Table) export(row Row) ExportedRow {
result.Set(k, row[k])
}

// check export=presence flags
if len(t.Columns) > 0 {
for _, col := range t.Columns {
if col.Export == "presence" {
if val, present := result.Get(col.Name); present && val != nil {
result.Set(col.Name, true)
}
}
}
}

return result
}

Expand Down

0 comments on commit c664c98

Please sign in to comment.