Skip to content

Commit

Permalink
Add VARBINARY to CursorWrapper (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
absci authored May 16, 2024
1 parent 970a66f commit ebd32e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions mssql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ def _as_sql_type(self, typ, value):
return 'TIME'
elif isinstance(value, UUID):
return 'uniqueidentifier'
elif isinstance(value, bytes):
return 'VARBINARY'
else:
raise NotImplementedError('Not supported type %s (%s)' % (type(value), repr(value)))

Expand Down
13 changes: 9 additions & 4 deletions testapp/tests/test_queries.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import django.db.utils
from django.db import connections
from django.test import TransactionTestCase
from django.db import connections, connection
from django.test import TransactionTestCase, TestCase

from ..models import Author
from ..models import Author, BinaryData

class TestTableWithTrigger(TransactionTestCase):
def test_insert_into_table_with_trigger(self):
Expand All @@ -27,4 +27,9 @@ def test_insert_into_table_with_trigger(self):
finally:
with connection.schema_editor() as cursor:
cursor.execute("DROP TRIGGER TestTrigger")
connection.features_class.can_return_rows_from_bulk_insert = old_return_rows_flag
connection.features_class.can_return_rows_from_bulk_insert = old_return_rows_flag

class TestBinaryfieldGroupby(TestCase):
def test_varbinary(self):
with connection.cursor() as cursor:
cursor.execute(f"SELECT binary FROM {BinaryData._meta.db_table} WHERE binary = %s GROUP BY binary", [bytes("ABC", 'utf-8')])

0 comments on commit ebd32e1

Please sign in to comment.