summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Medvinsky <me@dmedvinsky.name>2016-09-13 15:14:49 +0300
committerTim Graham <timograham@gmail.com>2016-09-19 20:19:57 -0400
commit1a9f6db5ffd2d5e71d73340ab59476572e05a728 (patch)
treea84837b893a2daa3bc8292f1fd5929d780badacd
parent358c6f21f8107d830a2f285d49d69bac24a98bdd (diff)
Fixed #27219 -- Changed cx_Oracle client encoding to AL32UTF8 to allow 4-byte characters.
-rw-r--r--django/db/backends/oracle/base.py2
-rw-r--r--tests/model_fields/test_charfield.py13
-rw-r--r--tests/model_fields/test_textfield.py13
3 files changed, 25 insertions, 3 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index c4dc075355..9fafd43b34 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -41,7 +41,7 @@ def _setup_environment(environ):
_setup_environment([
# Oracle takes client-side character set encoding from the environment.
- ('NLS_LANG', '.UTF8'),
+ ('NLS_LANG', '.AL32UTF8'),
# This prevents unicode from getting mangled by getting encoded into the
# potentially non-unicode database character set.
('ORA_NCHAR_LITERAL_REPLACE', 'TRUE'),
diff --git a/tests/model_fields/test_charfield.py b/tests/model_fields/test_charfield.py
index ca6e5ef9fe..82c7848777 100644
--- a/tests/model_fields/test_charfield.py
+++ b/tests/model_fields/test_charfield.py
@@ -1,5 +1,10 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from unittest import skipIf
+
from django.core.exceptions import ValidationError
-from django.db import models
+from django.db import connection, models
from django.test import SimpleTestCase, TestCase
from django.utils.functional import lazy
@@ -21,6 +26,12 @@ class TestCharField(TestCase):
def test_lookup_integer_in_charfield(self):
self.assertEqual(Post.objects.filter(title=9).count(), 0)
+ @skipIf(connection.vendor == 'mysql', 'See https://code.djangoproject.com/ticket/18392')
+ def test_emoji(self):
+ p = Post.objects.create(title='Smile 😀', body='Whatever.')
+ p.refresh_from_db()
+ self.assertEqual(p.title, 'Smile 😀')
+
class ValidationTests(SimpleTestCase):
diff --git a/tests/model_fields/test_textfield.py b/tests/model_fields/test_textfield.py
index 1c7a6891a8..e1d751f1be 100644
--- a/tests/model_fields/test_textfield.py
+++ b/tests/model_fields/test_textfield.py
@@ -1,4 +1,9 @@
-from django.db import models
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from unittest import skipIf
+
+from django.db import connection, models
from django.test import TestCase
from .models import Post
@@ -23,3 +28,9 @@ class TextFieldTests(TestCase):
def test_lookup_integer_in_textfield(self):
self.assertEqual(Post.objects.filter(body=24).count(), 0)
+
+ @skipIf(connection.vendor == 'mysql', 'See https://code.djangoproject.com/ticket/18392')
+ def test_emoji(self):
+ p = Post.objects.create(title='Whatever', body='Smile 😀.')
+ p.refresh_from_db()
+ self.assertEqual(p.body, 'Smile 😀.')