Skip to content

Commit

Permalink
Harmonise handling of text null values
Browse files Browse the repository at this point in the history
  • Loading branch information
pvaut committed May 2, 2014
1 parent feb20a3 commit 6065554
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion DQXDbTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _CreateSelectStatementSub_Compound(self,statm):

def _CreateSelectStatementSub_Comparison(self,statm):
#TODO: check that statm['ColName'] corresponds to a valid column name in the table (to avoid SQL injection)
if not(statm['Tpe'] in ['=', '<>', '<', '>', '<=', '>=', '!=', 'LIKE', 'CONTAINS', 'NOTCONTAINS', 'STARTSWITH', 'ISPRESENT', 'ISABSENT', '=FIELD', '<>FIELD', '<FIELD', '>FIELD', 'between']):
if not(statm['Tpe'] in ['=', '<>', '<', '>', '<=', '>=', '!=', 'LIKE', 'CONTAINS', 'NOTCONTAINS', 'STARTSWITH', 'ISPRESENT', 'ISABSENT', '=FIELD', '<>FIELD', '<FIELD', '>FIELD', 'between', 'ISEMPTYSTR', 'ISNOTEMPTYSTR']):
raise Exception("Invalid comparison statement {0}".format(statm['Tpe']))

processed=False
Expand All @@ -272,6 +272,18 @@ def _CreateSelectStatementSub_Comparison(self,statm):
self.querystring+=st
self.querystring_params+=st

if statm['Tpe']=='ISEMPTYSTR':
processed=True
st='{0}=""'.format(statm['ColName'])
self.querystring+=st
self.querystring_params+=st

if statm['Tpe']=='ISNOTEMPTYSTR':
processed=True
st='{0}<>""'.format(statm['ColName'])
self.querystring+=st
self.querystring_params+=st

if statm['Tpe']=='=FIELD':
processed=True
st='{0}={1}'.format(ToSafeIdentifier(statm['ColName']),ToSafeIdentifier(statm['ColName2']))
Expand Down

0 comments on commit 6065554

Please sign in to comment.