Skip to content

Commit

Permalink
sum string projection as integer of bool (#94)
Browse files Browse the repository at this point in the history
* sum string projection as integer of bool

* Added comments for the change
  • Loading branch information
rks0nax authored May 14, 2024
1 parent 5b4dec0 commit 5eed8bb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tap_mongodb/sync_strategies/oplog.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def transform_projection(projection):
return new_projection

temp_projection = {k:v for k, v in projection.items() if k != '_id'}
is_whitelist = sum([v for k, v in temp_projection.items()]) > 0
# int(bool(v)) will return 1 if v is any of non empty string, True or number > 0
# To avoid errors when v is a string or boolean, it is converted to int
is_whitelist = sum([int(bool(v)) for k, v in temp_projection.items()]) > 0

# If only '_id' is included in projection
if not temp_projection:
Expand Down

0 comments on commit 5eed8bb

Please sign in to comment.