@@ -283,7 +283,7 @@ def nullAndCastField(self, field):
283283 if Backend .isDbms (DBMS .SQLITE ):
284284 return field
285285
286- if field .startswith ("(CASE" ):
286+ if field .startswith ("(CASE" ) or field . startswith ( "(IIF" ) :
287287 nulledCastedField = field
288288 else :
289289 nulledCastedField = (queries [Backend .getIdentifiedDbms ()].cast .query % field ) if not conf .noCast else field
@@ -327,7 +327,7 @@ def nullCastConcatFields(self, fields):
327327 if not Backend .getDbms ():
328328 return fields
329329
330- if fields .startswith ("(CASE" ) or fields .startswith ("SUBSTR" ) or fields .startswith ("MID(" ):
330+ if fields .startswith ("(CASE" ) or fields .startswith ("(IIF" ) or fields . startswith ( " SUBSTR" ) or fields .startswith ("MID(" ):
331331 nulledCastedConcatFields = fields
332332 else :
333333 fields = fields .replace (", " , "," )
@@ -598,7 +598,7 @@ def forgeInbandQuery(self, query, position, count, comment, prefix, suffix, char
598598 inbandQuery += query [conditionIndex :]
599599
600600 if Backend .getIdentifiedDbms () in FROM_TABLE :
601- if " FROM " not in inbandQuery or "(CASE " in inbandQuery :
601+ if " FROM " not in inbandQuery or "(CASE " in inbandQuery or "(IIF" in inbandQuery :
602602 inbandQuery += FROM_TABLE [Backend .getIdentifiedDbms ()]
603603
604604 if intoRegExp :
@@ -748,7 +748,7 @@ def forgeCaseStatement(self, expression):
748748 if Backend .getIdentifiedDbms () is not None and hasattr (queries [Backend .getIdentifiedDbms ()], "case" ):
749749 caseExpression = queries [Backend .getIdentifiedDbms ()].case .query % expression
750750
751- if Backend .getIdentifiedDbms () in FROM_TABLE and not caseExpression .upper ().endswith (FROM_TABLE [Backend .getIdentifiedDbms ()]):
751+ if "(IIF" not in caseExpression and Backend .getIdentifiedDbms () in FROM_TABLE and not caseExpression .upper ().endswith (FROM_TABLE [Backend .getIdentifiedDbms ()]):
752752 caseExpression += FROM_TABLE [Backend .getIdentifiedDbms ()]
753753
754754 return caseExpression
0 commit comments