Fixed #11487: pass long strings to Oracle as CLOB rather than NCLOB to prevent an encoding bug that occurs in some installations.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11285 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2d781aae5f
commit
bbac0cc965
|
@ -345,7 +345,7 @@ class OracleParam(object):
|
||||||
"""
|
"""
|
||||||
Wrapper object for formatting parameters for Oracle. If the string
|
Wrapper object for formatting parameters for Oracle. If the string
|
||||||
representation of the value is large enough (greater than 4000 characters)
|
representation of the value is large enough (greater than 4000 characters)
|
||||||
the input size needs to be set as NCLOB. Alternatively, if the parameter
|
the input size needs to be set as CLOB. Alternatively, if the parameter
|
||||||
has an `input_size` attribute, then the value of the `input_size` attribute
|
has an `input_size` attribute, then the value of the `input_size` attribute
|
||||||
will be used instead. Otherwise, no input size will be set for the
|
will be used instead. Otherwise, no input size will be set for the
|
||||||
parameter when executing the query.
|
parameter when executing the query.
|
||||||
|
@ -360,8 +360,8 @@ class OracleParam(object):
|
||||||
# If parameter has `input_size` attribute, use that.
|
# If parameter has `input_size` attribute, use that.
|
||||||
self.input_size = param.input_size
|
self.input_size = param.input_size
|
||||||
elif isinstance(param, basestring) and len(param) > 4000:
|
elif isinstance(param, basestring) and len(param) > 4000:
|
||||||
# Mark any string param greater than 4000 characters as an NCLOB.
|
# Mark any string param greater than 4000 characters as a CLOB.
|
||||||
self.input_size = Database.NCLOB
|
self.input_size = Database.CLOB
|
||||||
else:
|
else:
|
||||||
self.input_size = None
|
self.input_size = None
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,21 @@ class Callproc(unittest.TestCase):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
class LongString(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_long_string(self):
|
||||||
|
# If the backend is Oracle, test that we can save a text longer
|
||||||
|
# than 4000 chars and read it properly
|
||||||
|
if settings.DATABASE_ENGINE == 'oracle':
|
||||||
|
c = connection.cursor()
|
||||||
|
c.execute('CREATE TABLE ltext ("TEXT" NCLOB)')
|
||||||
|
long_str = ''.join([unicode(x) for x in xrange(4000)])
|
||||||
|
c.execute('INSERT INTO ltext VALUES (%s)',[long_str])
|
||||||
|
c.execute('SELECT text FROM ltext')
|
||||||
|
row = c.fetchone()
|
||||||
|
c.execute('DROP TABLE ltext')
|
||||||
|
self.assertEquals(long_str, row[0].read())
|
||||||
|
|
||||||
def connection_created_test(sender, **kwargs):
|
def connection_created_test(sender, **kwargs):
|
||||||
print 'connection_created signal'
|
print 'connection_created signal'
|
||||||
|
|
Loading…
Reference in New Issue