mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Add introspection support for BinaryField
This commit is contained in:
parent
d680a3f447
commit
c5a25c2771
5 changed files with 10 additions and 2 deletions
|
@ -10,6 +10,7 @@ class Reporter(models.Model):
|
|||
last_name = models.CharField(max_length=30)
|
||||
email = models.EmailField()
|
||||
facebook_user_id = models.BigIntegerField(null=True)
|
||||
raw_data = models.BinaryField(null=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('first_name', 'last_name')
|
||||
|
|
|
@ -60,9 +60,13 @@ class IntrospectionTests(TestCase):
|
|||
def test_get_table_description_types(self):
|
||||
cursor = connection.cursor()
|
||||
desc = connection.introspection.get_table_description(cursor, Reporter._meta.db_table)
|
||||
# The MySQL exception is due to the cursor.description returning the same constant for
|
||||
# text and blob columns. TODO: use information_schema database to retrieve the proper
|
||||
# field type on MySQL
|
||||
self.assertEqual(
|
||||
[datatype(r[1], r) for r in desc],
|
||||
['IntegerField', 'CharField', 'CharField', 'CharField', 'BigIntegerField']
|
||||
['IntegerField', 'CharField', 'CharField', 'CharField',
|
||||
'BigIntegerField', 'BinaryField' if connection.vendor != 'mysql' else 'TextField']
|
||||
)
|
||||
|
||||
# The following test fails on Oracle due to #17202 (can't correctly
|
||||
|
@ -85,7 +89,7 @@ class IntrospectionTests(TestCase):
|
|||
desc = connection.introspection.get_table_description(cursor, Reporter._meta.db_table)
|
||||
self.assertEqual(
|
||||
[r[6] for r in desc],
|
||||
[False, False, False, False, True]
|
||||
[False, False, False, False, True, True]
|
||||
)
|
||||
|
||||
# Regression test for #9991 - 'real' types in postgres
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue