Kaydet (Commit) d696fcca authored tarafından Sergey Fedoseev's avatar Sergey Fedoseev Kaydeden (comit) Tim Graham

Fixed #29209 -- Fixed Cast() with TextField on MySQL and Oracle.

üst c12745f6
......@@ -18,6 +18,7 @@ class DatabaseOperations(BaseDatabaseOperations):
}
cast_data_types = {
'CharField': 'char(%(max_length)s)',
'TextField': 'char',
'IntegerField': 'signed integer',
'BigIntegerField': 'signed integer',
'SmallIntegerField': 'signed integer',
......
......@@ -51,6 +51,9 @@ END;
# Oracle doesn't support string without precision; use the max string size.
cast_char_field_without_max_length = 'NVARCHAR2(2000)'
cast_data_types = {
'TextField': cast_char_field_without_max_length,
}
def cache_key_culling_sql(self):
return """
......
......@@ -74,3 +74,6 @@ class CastTests(TestCase):
"""
list(Author.objects.annotate(cast_float=Cast(Avg('age'), models.FloatField())))
self.assertIn('(AVG("db_functions_author"."age"))::double precision', connection.queries[-1]['sql'])
def test_cast_to_text_field(self):
self.assertEqual(Author.objects.values_list(Cast('age', models.TextField()), flat=True).get(), '1')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment