diff --git a/lib/core/agent.py b/lib/core/agent.py
index b8c060335..30df3ccb7 100644
--- a/lib/core/agent.py
+++ b/lib/core/agent.py
@@ -331,10 +331,11 @@ class Agent(object):
rootQuery = queries[Backend.getIdentifiedDbms()]
if field.startswith("(CASE") or field.startswith("(IIF") or\
- conf.noCast or Backend.isDbms(DBMS.SQLITE) and not isDBMSVersionAtLeast('3'):
+ conf.noCast:
nulledCastedField = field
else:
- nulledCastedField = rootQuery.cast.query % field
+ if not (Backend.isDbms(DBMS.SQLITE) and not isDBMSVersionAtLeast('3')):
+ nulledCastedField = rootQuery.cast.query % field
if Backend.getIdentifiedDbms() in (DBMS.ACCESS,):
nulledCastedField = rootQuery.isnull.query % (nulledCastedField, nulledCastedField)
else:
diff --git a/xml/queries.xml b/xml/queries.xml
index 254242824..cb8b8c431 100644
--- a/xml/queries.xml
+++ b/xml/queries.xml
@@ -296,7 +296,7 @@
-
+