Fix issue #2015
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 3154d14..9bd535b 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -644,17 +644,11 @@
 				? $this->_group_get_type('')
 				: $this->_group_get_type($type);
 
-			if (is_null($v) && ! $this->_has_operator($k))
-			{
-				// value appears not to have been set, assign the test to IS NULL
-				$k .= ' IS NULL';
-			}
-
 			if ( ! is_null($v))
 			{
 				if ($escape === TRUE)
 				{
-					$v = ' '.(is_int($v) ? $v : $this->escape($v));
+					$v = ' '.$this->escape($v);
 				}
 
 				if ( ! $this->_has_operator($k))
@@ -662,6 +656,11 @@
 					$k .= ' = ';
 				}
 			}
+			elseif ( ! $this->_has_operator($k))
+			{
+				// value appears not to have been set, assign the test to IS NULL
+				$k .= ' IS NULL';
+			}
 
 			$this->{$qb_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape);
 			if ($this->qb_caching === TRUE)
@@ -2540,7 +2539,7 @@
 	{
 		$str = trim($str);
 
-		if (empty($str))
+		if (empty($str) OR ctype_digit($str) OR (string) (float) $str === $str OR in_array(strtoupper($str), array('TRUE', 'FALSE'), TRUE))
 		{
 			return TRUE;
 		}
@@ -2553,7 +2552,7 @@
 				? array('"', "'") : array("'");
 		}
 
-		return (ctype_digit($str) OR in_array($str[0], $_str, TRUE));
+		return in_array($str[0], $_str, TRUE);
 	}
 
 	// --------------------------------------------------------------------