Skip to content

Commit

Permalink
Supercedes disqus#11.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamahuman committed Jan 16, 2021
1 parent 89db022 commit 8f54767
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bitfield/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ def test_regression_1425(self):
self.assertTrue(instance.flags.FLAG_2)
self.assertTrue(instance.flags.FLAG_3)

cursor = connection.cursor()
flags_field = BitFieldTestModel._meta.get_field('flags')
flags_db_column = flags_field.db_column or flags_field.name
cursor.execute("INSERT INTO %s (%s) VALUES (-1)" % (BitFieldTestModel._meta.db_table, flags_db_column))
# There should only be the one row we inserted through the cursor.
# Bypass BitField.to_python and insert (-1) directly.
instance = BitFieldTestModel()
instance.__dict__['flags'] = models.Value(-1, output_field=models.IntegerField())
instance.save()

# There should only be the one row we inserted with a direct value.
instance = BitFieldTestModel.objects.get(flags=-1)
self.assertTrue(instance.flags.FLAG_0)
self.assertTrue(instance.flags.FLAG_1)
Expand Down

0 comments on commit 8f54767

Please sign in to comment.