Skip to content

Commit

Permalink
Merge remote-tracking branch 'iamahuman/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
tahajahangir committed May 27, 2018
2 parents 3e3dadb + 2ca5f2f commit 35fdc8a
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions bitfield/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def process_lhs(self, qn, connection, lhs=None):
lhs_sql = lhs_sql + ' & %s'
else:
lhs_sql = lhs_sql + ' | %s'
params.extend(self.get_db_prep_lookup(self.rhs, connection)[1])
params.extend(self.process_rhs(qn, connection)[1])
return lhs_sql, params

def get_db_prep_lookup(self, value, connection, prepared=False):
Expand All @@ -57,16 +57,9 @@ def as_sql(self, qn, connection):
This will be called by Where.as_sql()
"""
engine = connection.settings_dict['ENGINE'].rsplit('.', -1)[-1]
if engine.startswith('postgres'):
XOR_OPERATOR = '#'
elif engine.startswith('sqlite'):
raise NotImplementedError
else:
XOR_OPERATOR = '^'

if self.bit:
return ("%s.%s | %d" % (qn(self.table_alias), qn(self.column), self.bit.mask),
[])
return ("%s.%s %s %d" % (qn(self.table_alias), qn(self.column), XOR_OPERATOR, self.bit.mask),
return ("%s.%s & ~%d" % (qn(self.table_alias), qn(self.column), self.bit.mask),
[])

0 comments on commit 35fdc8a

Please sign in to comment.