Skip to content

Commit

Permalink
Merge pull request #10 from TCB13/master
Browse files Browse the repository at this point in the history
Better query error handling.
  • Loading branch information
Nuno Chaves authored Jan 10, 2019
2 parents 43784e5 + 9ecc9c5 commit 42096ef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/CosmosDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ public function query($rid_id, $rid_col, $query, $isCrossPartition = false)
// This is a first chance (internal) exception that all newer clients will know how to
// handle gracefully. This exception is traced, but unless you see it bubble up as an
// exception (which only happens on older SDK clients), then you can safely ignore this message.
if ($responseError->code === "BadRequest" && $isCrossPartition) {
if ($isCrossPartition && $responseError->code === "BadRequest" && strpos($responseError->message, "cross partition query can not be directly served by the gateway") !== false) {
$headers["x-ms-documentdb-partitionkeyrangeid"] = $this->getPkFullRange($rid_id, $rid_col);
$result = $this->request("/dbs/" . $rid_id . "/colls/" . $rid_col . "/docs", "POST", $headers, $query);
} else {
throw $e;
}

}

return $result;
Expand Down

0 comments on commit 42096ef

Please sign in to comment.