Skip to content

Commit

Permalink
Merge pull request #1923 from yphillip/join-merge-bug-fix
Browse files Browse the repository at this point in the history
Join merge bug fix (proposed solution for #1843)
  • Loading branch information
anjakefala authored Jun 21, 2023
2 parents b401b34 + e4c393e commit 08c4e00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions tests/join-merge.vd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
sheet col row longname input keystrokes comment
open-file tests/join-merge-1.jsonl o
open-file tests/join-merge-2.jsonl o
join-merge-2 colA key-col !
open-file tests/join-merge-1.jsonl o
join-merge-1 colA key-col !
join-merge-2 join-sheets-top2 merge &
join-merge-2+join-merge-1 colA type-int #
join-merge-2+join-merge-1 colA sort-asc [
join-merge-2 colA key-col !
join-merge-1 join-sheets-top2 merge &
join-merge-1+join-merge-2 colA type-int #
join-merge-1+join-merge-2 colA sort-asc [
6 changes: 3 additions & 3 deletions visidata/features/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def openJoin(sheet, others, jointype=''):
'append': 'all rows from all sheets; columns from all sheets',
'concat': 'all rows from all sheets; columns and type from first sheet',
'extend': 'only rows from first sheet; type from first sheet; columns from all sheets',
'merge': 'merge differences from other sheets into first sheet',
'merge': 'merge differences from other sheets into first sheet (including new rows)',
}.items()]

def joinkey(sheet, row):
Expand Down Expand Up @@ -134,14 +134,14 @@ def recalc(self, sheet=None):

class MergeColumn(Column):
def calcValue(self, row):
for vs, c in self.cols.items():
for vs, c in reversed(list(self.cols.items())):
if c:
v = c.getTypedValue(row[vs])
if v and not isinstance(v, TypedWrapper):
return v

def putValue(self, row, value):
for vs, c in reversed(self.cols.items()):
for vs, c in reversed(list(self.cols.items())):
c.setValue(row[vs], value)

def isDiff(self, row, value):
Expand Down

0 comments on commit 08c4e00

Please sign in to comment.