diff --git a/includes/database/query.inc b/includes/database/query.inc
index 23b652f..f2e2cbf 100644
--- a/includes/database/query.inc
+++ b/includes/database/query.inc
@@ -1719,6 +1719,11 @@ class DatabaseCondition implements QueryConditionInterface, Countable {
    * Implements QueryConditionInterface::compile().
    */
   public function compile(DatabaseConnection $connection, QueryPlaceholderInterface $queryPlaceholder = NULL) {
+    // Rebuild the output if it's used on another query.
+    if (spl_object_hash($queryPlaceholder) != $this->queryPlaceholder) {
+      $this->changed = TRUE;
+    }
+
     if ($this->changed) {
       $condition_fragments = array();
       $arguments = array();
@@ -1788,6 +1793,7 @@ class DatabaseCondition implements QueryConditionInterface, Countable {
       $this->changed = FALSE;
       $this->stringVersion = implode($conjunction, $condition_fragments);
       $this->arguments = $arguments;
+      $this->lastObjectHash = spl_object_hash($queryPlaceholder);
     }
   }
 
