Code

Ticket #11487: base_with_tests.diff

File base_with_tests.diff, 1.9 KB (added by rafax, 5 years ago)

Patch with regression test added.

Line 
1Index: django/db/backends/oracle/base.py
2===================================================================
3--- django/db/backends/oracle/base.py   (revision 11280)
4+++ django/db/backends/oracle/base.py   (working copy)
5@@ -360,8 +360,8 @@
6             # If parameter has `input_size` attribute, use that.
7             self.input_size = param.input_size
8         elif isinstance(param, basestring) and len(param) > 4000:
9-            # Mark any string param greater than 4000 characters as an NCLOB.
10-            self.input_size = Database.NCLOB
11+            # Mark any string param greater than 4000 characters as a CLOB.
12+            self.input_size = Database.CLOB
13         else:
14             self.input_size = None
15 
16Index: tests/regressiontests/backends/tests.py
17===================================================================
18--- tests/regressiontests/backends/tests.py     (revision 11280)
19+++ tests/regressiontests/backends/tests.py     (working copy)
20@@ -17,7 +17,25 @@
21             return True
22         else:
23             return True
24+           
25+class LongString(unittest.TestCase):
26 
27+    def test_long_string(self):
28+        # If the backend is Oracle, test that we can save a text longer
29+        # than 4000 chars and read it properly
30+        if settings.DATABASE_ENGINE == 'oracle':
31+            c = connection.cursor()
32+            c.execute('CREATE TABLE ltext ("TEXT" CLOB)')
33+            transaction.commit_unless_managed()
34+            long_str = ''.join( unicode(x) for x in xrange(4000) )
35+            c.execute('INSERT INTO ltext VALUES (%s)',[long_str])
36+            transaction.commit_unless_managed()
37+            c.execute('SELECT text FROM ltext')
38+            row = c.fetchone()
39+            c.execute('DROP TABLE ltext')
40+            transaction.commit_unless_managed()
41+            self.assertEquals(long_str, row[0].read())
42+
43 def connection_created_test(sender, **kwargs):
44     print 'connection_created signal'
45