8000 Add more test · PyMySQL/PyMySQL@6932b0a · GitHub
[go: up one dir, main page]

Skip to content

Commit 6932b0a

Browse files
committed
Add more test
1 parent a568397 commit 6932b0a

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

pymysql/converters.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,6 @@ def convert_set(s):
333333
return set(s.split(","))
334334

335335

336-
def convert_json(b):
337-
# JSON is returned as binary data.
338-
# Decode with utf-8 regardless connection encoding.
339-
return b.decode('utf-8')
340-
341-
342336
def through(x):
343337
return x
344338

@@ -416,7 +410,6 @@ def convert_characters(connection, field, data):
416410
FIELD_TYPE.VARCHAR: through,
417411
FIELD_TYPE.DECIMAL: Decimal,
418412
FIELD_TYPE.NEWDECIMAL: Decimal,
419-
FIELD_TYPE.JSON: convert_json,
420413
}
421414

422415

pymysql/tests/test_basic.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,17 @@ def test_json(self):
253253
primary key (id)
254254
);""")
255255
cur = conn.cursor()
256+
256257
json_str = u'{"hello": "こんにちは"}'
257258
cur.execute("INSERT INTO test_json (id, `json`) values (42, %s)", (json_str,))
258259
cur.execute("SELECT `json` from `test_json` WHERE `id`=42")
259260
res = cur.fetchone()[0]
260261
self.assertEqual(json.loads(res), json.loads(json_str))
261262

263+
cur.execute("SELECT CAST(%s AS JSON) AS x", (json_str,))
264+
res = cur.fetchone()[0]
265+
self.assertEqual(json.loads(res), json.loads(json_str))
266+
262267

263268
class TestBulkInserts(base.PyMySQLTestCase):
264269

0 commit comments

Comments
 (0)
0