Commit 70aab098 authored by Jérome Perrin's avatar Jérome Perrin

sqlvar py3 ( to check )

parent 35405e6c
......@@ -38,17 +38,17 @@ class TestSQLVar(ERP5TypeTestCase):
connection_id='erp5_sql_connection',
arguments_src='value',
src='<dtml-sqlvar value type="string">')
self.assertEqual(sqlmethod(value='', src__=1), "''")
self.assertEqual(sqlmethod(value=None, src__=1), 'null')
self.assertEqual(sqlmethod(value='', src__=1), b"''")
self.assertEqual(sqlmethod(value=None, src__=1), b'null')
sqlmethod.edit(src='<dtml-sqlvar value type="string" optional>')
self.assertEqual(sqlmethod(value='', src__=1), "''")
self.assertEqual(sqlmethod(value=None, src__=1), 'null')
self.assertEqual(sqlmethod(value='', src__=1), b"''")
self.assertEqual(sqlmethod(value=None, src__=1), b'null')
sqlmethod.edit(src='<dtml-sqlvar value type="nb">')
self.assertRaises(ValueError, sqlmethod, value='', src__=1)
self.assertEqual(sqlmethod(value=None, src__=1), 'null')
self.assertEqual(sqlmethod(value=None, src__=1), b'null')
sqlmethod.edit(src='<dtml-sqlvar value type="nb" optional>')
self.assertEqual(sqlmethod(value='', src__=1), 'null')
self.assertEqual(sqlmethod(value=None, src__=1), 'null')
self.assertEqual(sqlmethod(value='', src__=1), b'null')
self.assertEqual(sqlmethod(value=None, src__=1), b'null')
......@@ -110,13 +110,13 @@ else: # For easy diff with original (ZSQLMethods 3.14)
v = expr(md)
except Exception:
if 'optional' in args and args['optional']:
return 'null'
return b'null'
if not isinstance(expr, StringTypes):
raise
raise ValueError('Missing input variable, <em>%s</em>' % name)
if v is None:
return 'null'
return b'null'
if t == 'int':
try:
......@@ -162,7 +162,7 @@ else: # For easy diff with original (ZSQLMethods 3.14)
v = str(v)
if not v and t == 'nb':
if 'optional' in args and args['optional']:
return 'null'
return b'null'
else:
err = 'Invalid empty string value for <em>%s</em>' % name
raise ValueError(err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment