Skip to content

Commit dbf1bc3

Browse files
committed
Propagate the fix to the py3compat version.
1 parent 6afdd02 commit dbf1bc3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

rdflib_sqlalchemy/SQLAlchemy.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,16 @@ def pycompat_executeSQL(self, cursor, qStr, params=None, paramList=False):
352352
except:
353353
pass
354354

355-
def locproc(item):
355+
def py_to_sql(param):
356+
if param is None:
357+
return 'NULL'
358+
if isinstance(param, int):
359+
return param
356360
try:
357-
return "'%s'" % item.decode()
361+
return "'%s'" % param.decode()
358362
except:
359-
return item
363+
return param
364+
360365
# _logger.debug("SQLGenerator %s - %s" % (qStr,params))
361366
if not params:
362367
querystr = qStr.replace('"', "'")
@@ -369,7 +374,7 @@ def locproc(item):
369374
elif paramList:
370375
raise Exception("Not supported!")
371376
else:
372-
params = tuple([locproc(item) for item in params])
377+
params = tuple(map(py_to_sql, params))
373378
querystr = qStr.replace('"', "'")
374379
querystr = querystr % params
375380
# if isinstance(qStr, bytes): qStr = qStr.decode()

0 commit comments

Comments
 (0)