File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,12 @@ class Blob(bytes):
3535 datetime .datetime : sqlalchemy .types .DateTime ,
3636
3737 Blob : sqlalchemy .types .LargeBinary ,
38- bytes : sqlalchemy .types .LargeBinary ,
3938}
4039
40+ if bytes is not str :
41+ # On 2.7, bytes *is* str, so we don't want to overwrite that.
42+ PYTHON_SQLITE_TYPE_MAP [bytes ] = sqlalchemy .types .LargeBinary
43+
4144try :
4245 PYTHON_SQLITE_TYPE_MAP [long ] = sqlalchemy .types .BigInteger
4346except NameError :
Original file line number Diff line number Diff line change 22from __future__ import absolute_import
33
44import datetime
5+ import json
56import os
67import re
78import shutil
@@ -195,7 +196,7 @@ def test_add_column(self):
195196
196197 script = dedent (u"""
197198 import scraperwiki
198- scraperwiki.sql.save(['id'], dict(id=1, a="bar\xaa ", b="foo\xaa "))
199+ scraperwiki.sql.save(['id'], dict(id=1, a=u "bar\xaa ", b=u "foo\xaa "))
199200 """ )
200201 with open ("/dev/null" ) as null :
201202 process = Popen ([sys .executable , "-c" , script ],
@@ -218,6 +219,12 @@ def test_save_string(self):
218219 (u'LeTourneau\u1234 ' ,)]
219220 )
220221
222+ # Ensure we can round-trip a string and then json encode it.
223+ # https://github.com/scraperwiki/scraperwiki-python/pull/85
224+ scraperwiki .sql .save ([], {"test" : "teststring" }, table_name = "teststring" )
225+ data = scraperwiki .sql .select ("* FROM teststring" )
226+ json .dumps (data )
227+
221228 def test_save_twice (self ):
222229 self .save_and_check (
223230 {u"modelNumber\xaa " : 293 }, u"modelNumbers" , [(293 ,)]
You can’t perform that action at this time.
0 commit comments