mirror of
				https://github.com/django/django.git
				synced 2025-11-04 13:39:16 +00:00 
			
		
		
		
	Added a flag for the ability to introspect nullable fields.
Previously this was conflated with another Oracle-specific behavior.
This commit is contained in:
		
							parent
							
								
									237c229b91
								
							
						
					
					
						commit
						a03d38ddd4
					
				
					 3 changed files with 8 additions and 5 deletions
				
			
		| 
						 | 
					@ -571,6 +571,9 @@ class BaseDatabaseFeatures(object):
 | 
				
			||||||
    # Can the backend determine reliably the length of a CharField?
 | 
					    # Can the backend determine reliably the length of a CharField?
 | 
				
			||||||
    can_introspect_max_length = True
 | 
					    can_introspect_max_length = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Can the backend determine reliably if a field is nullable?
 | 
				
			||||||
 | 
					    can_introspect_null = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Confirm support for introspected foreign keys
 | 
					    # Confirm support for introspected foreign keys
 | 
				
			||||||
    # Every database can do this reliably, except MySQL,
 | 
					    # Every database can do this reliably, except MySQL,
 | 
				
			||||||
    # which can't do it for MyISAM tables
 | 
					    # which can't do it for MyISAM tables
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,6 +112,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
 | 
				
			||||||
    supports_tablespaces = True
 | 
					    supports_tablespaces = True
 | 
				
			||||||
    supports_sequence_reset = False
 | 
					    supports_sequence_reset = False
 | 
				
			||||||
    can_introspect_max_length = False
 | 
					    can_introspect_max_length = False
 | 
				
			||||||
 | 
					    can_introspect_null = False
 | 
				
			||||||
    can_introspect_time_field = False
 | 
					    can_introspect_time_field = False
 | 
				
			||||||
    atomic_transactions = False
 | 
					    atomic_transactions = False
 | 
				
			||||||
    supports_combined_alters = False
 | 
					    supports_combined_alters = False
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
from __future__ import unicode_literals
 | 
					from __future__ import unicode_literals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from django.db import connection
 | 
					from django.db import connection
 | 
				
			||||||
from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
 | 
					from django.test import TestCase, skipUnlessDBFeature
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .models import Reporter, Article
 | 
					from .models import Reporter, Article
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,10 +73,9 @@ class IntrospectionTests(TestCase):
 | 
				
			||||||
            [30, 30, 75]
 | 
					            [30, 30, 75]
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Oracle forces null=True under the hood in some cases (see
 | 
					    # The following test fails on Oracle. Since it forces null=True under the
 | 
				
			||||||
    # https://docs.djangoproject.com/en/dev/ref/databases/#null-and-empty-strings)
 | 
					    # hood in some cases, its idea about null_ok is different from ours.
 | 
				
			||||||
    # so its idea about null_ok in cursor.description is different from ours.
 | 
					    @skipUnlessDBFeature('can_introspect_null')
 | 
				
			||||||
    @skipIfDBFeature('interprets_empty_strings_as_nulls')
 | 
					 | 
				
			||||||
    def test_get_table_description_nullable(self):
 | 
					    def test_get_table_description_nullable(self):
 | 
				
			||||||
        with connection.cursor() as cursor:
 | 
					        with connection.cursor() as cursor:
 | 
				
			||||||
            desc = connection.introspection.get_table_description(cursor, Reporter._meta.db_table)
 | 
					            desc = connection.introspection.get_table_description(cursor, Reporter._meta.db_table)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue