Fix for logic Query::queryScalar uses to check for SELECT DISTINCT