Skip to content

Commit

Permalink
gtid: implement various evaluation methods for gtidset
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Gautier <[email protected]>
  • Loading branch information
Arthur Gautier committed Nov 22, 2019
1 parent 022fd34 commit 1842248
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pymysqlreplication/gtid.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ def merge_gtid(self, gtid):
self.gtids = new_gtids

def __contains__(self, other):
if isinstance(other, GtidSet):
return all(other_gtid in self.gtids for other_gtid in other.gtids)
if isinstance(other, Gtid):
return any(other in x for x in self.gtids)
raise NotImplementedError
Expand All @@ -296,6 +298,13 @@ def __add__(self, other):
new = GtidSet(self.gtids)
new.merge_gtid(other)
return new

if isinstance(other, GtidSet):
new = GtidSet(self.gtids)
for gtid in other.gtids:
new.merge_gtid(gtid)
return new

raise NotImplementedError

def __str__(self):
Expand Down

0 comments on commit 1842248

Please sign in to comment.