[1.7.x] Fixed schema test for Oracle 11.2.0.1 which is used in Django Project's CI.
Refs #23073 Workaround.
Refs #22738 Repeats the mysql "offense". When the issue is solved, the
Oracle special case should be made to play with the solution (that is,
Oracle should be fixed the same way that mysql and the 3rd-party backneds
are).
Backport of 56252e7
from master
This commit is contained in:
parent
fbe4507623
commit
588f66d182
|
@ -725,14 +725,31 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def oracle_version(self):
|
def oracle_full_version(self):
|
||||||
with self.temporary_connection():
|
with self.temporary_connection():
|
||||||
version = self.connection.version
|
return self.connection.version
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def oracle_version(self):
|
||||||
try:
|
try:
|
||||||
return int(version.split('.')[0])
|
return int(self.oracle_full_version.split('.')[0])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def version_has_default_introspection_bug(self):
|
||||||
|
"""
|
||||||
|
Some versions of Oracle -- we've seen this on 11.2.0.1 and suspect
|
||||||
|
it goes back -- have a weird bug where, when an integer column is
|
||||||
|
defined with a default, its precision is later reported on introspection
|
||||||
|
as 0, regardless of the real precision. For Django introspection, this
|
||||||
|
means that such columns are reported as IntegerField even if they are
|
||||||
|
really BigIntegerField or BooleanField.
|
||||||
|
|
||||||
|
The bug is solved in Oracle 11.2.0.2 and up.
|
||||||
|
"""
|
||||||
|
return self.oracle_full_version < '11.2.0.2'
|
||||||
|
|
||||||
|
|
||||||
class OracleParam(object):
|
class OracleParam(object):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -318,6 +318,9 @@ class SchemaTests(TransactionTestCase):
|
||||||
if connection.vendor == 'mysql':
|
if connection.vendor == 'mysql':
|
||||||
self.assertEqual(field_type, 'IntegerField')
|
self.assertEqual(field_type, 'IntegerField')
|
||||||
self.assertEqual(field_info.precision, 1)
|
self.assertEqual(field_info.precision, 1)
|
||||||
|
elif connection.vendor == 'oracle' and connection.version_has_default_introspection_bug:
|
||||||
|
self.assertEqual(field_type, 'IntegerField')
|
||||||
|
self.assertEqual(field_info.precision, 0)
|
||||||
else:
|
else:
|
||||||
self.assertEqual(field_type, 'BooleanField')
|
self.assertEqual(field_type, 'BooleanField')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue