From 6ca74d723a962373a858c7d13cc09fb57dddde69 Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Wed, 16 Feb 2022 23:30:29 +1100 Subject: [PATCH] fix a bug in function ReplaceOfferForResource caused by a change from v0.1.5 --- RELEASE-NOTES.md | 4 ++++ gocosmos.go | 2 +- restclient.go | 8 +++++++- restclient_test.go | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 6e713ff..c4f71df 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,9 @@ # gocosmos release notes +## 2022-02-16 - v0.1.6 + +- REST client & Driver for `database/sql`: fix a bug in function `ReplaceOfferForResource` caused by a change from v0.1.5. + ## 2022-02-16 - v0.1.5 - Fix a bug where no-parameterized query returns error. diff --git a/gocosmos.go b/gocosmos.go index 3aca39d..2e4dd13 100644 --- a/gocosmos.go +++ b/gocosmos.go @@ -5,5 +5,5 @@ package gocosmos const ( // Version of package gocosmos. - Version = "0.1.5" + Version = "0.1.6" ) diff --git a/restclient.go b/restclient.go index 9fb34e5..51b1eca 100644 --- a/restclient.go +++ b/restclient.go @@ -747,7 +747,13 @@ func (c *RestClient) ReplaceOfferForResource(rid string, ru, maxru int) *RespRep } params["content"] = content req := c.buildJsonRequest(method, url, params) - req = c.addAuthHeader(req, method, "offers", getResult.OfferInfo.Rid) + /* + * [btnguyen2k] 2022-02-16 + * OfferInfo.Rid is returned from the server, but it _must_ be lower-cased when we send back to the server for + * issuing the 'replace-offer' request. + * Not sure if this is intended or a bug of CosmosDB. + */ + req = c.addAuthHeader(req, method, "offers", strings.ToLower(getResult.OfferInfo.Rid)) for k, v := range headers { req.Header.Set(k, v) } diff --git a/restclient_test.go b/restclient_test.go index 81ffd43..c113594 100644 --- a/restclient_test.go +++ b/restclient_test.go @@ -1390,7 +1390,7 @@ func TestRestClient_QueryAllDocuments(t *testing.T) { fmt.Printf("\t%s - total RU charged: %0.3f\n", name+"/Insert", totalRu) query := QueryReq{DbName: dbname, CollName: collname, MaxItemCount: 10, ConsistencyLevel: "Session", SessionToken: sessionToken, - Query: "SELECT * FROM c", + Query: "SELECT * FROM c", CrossPartitionEnabled: true, } var result *RespQueryDocs