mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2026-03-13 08:00:02 +08:00
add surrogate escape for callproc and test case for that (#104)
This commit is contained in:
committed by
INADA Naoki
parent
fb842fbdd5
commit
c7d2168939
@@ -347,7 +347,7 @@ class BaseCursor(object):
|
||||
q = "SET @_%s_%d=%s" % (procname, index,
|
||||
db.literal(arg))
|
||||
if isinstance(q, unicode):
|
||||
q = q.encode(db.unicode_literal.charset)
|
||||
q = q.encode(db.unicode_literal.charset, 'surrogateescape')
|
||||
self._query(q)
|
||||
self.nextset()
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import capabilities
|
||||
from datetime import timedelta
|
||||
import unittest
|
||||
@@ -43,7 +44,7 @@ class test_MySQLdb(capabilities.DatabaseTest):
|
||||
c = self.cursor
|
||||
self.create_table(('pos INT', 'tree CHAR(20)'))
|
||||
c.executemany("INSERT INTO %s (pos,tree) VALUES (%%s,%%s)" % self.table,
|
||||
list(enumerate('ash birch cedar larch pine'.split())))
|
||||
list(enumerate('ash birch cedar Lärche pine'.split())))
|
||||
db.commit()
|
||||
|
||||
c.execute("""
|
||||
@@ -54,7 +55,7 @@ class test_MySQLdb(capabilities.DatabaseTest):
|
||||
""" % self.table)
|
||||
db.commit()
|
||||
|
||||
c.callproc('test_sp', ('larch',))
|
||||
c.callproc('test_sp', ('Lärche',))
|
||||
rows = c.fetchall()
|
||||
self.assertEqual(len(rows), 1)
|
||||
self.assertEqual(rows[0][0], 3)
|
||||
|
||||
Reference in New Issue
Block a user