From 8f599b65290f211c809459c655c644e332daf71e Mon Sep 17 00:00:00 2001 From: Yang Xiufeng Date: Thu, 12 Dec 2024 11:20:38 +0800 Subject: [PATCH 1/2] fix: compatible with old servers when login 404 --- core/src/client.rs | 6 ++---- core/src/error.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/client.rs b/core/src/client.rs index d21855c6..aebb3abf 100644 --- a/core/src/client.rs +++ b/core/src/client.rs @@ -649,9 +649,7 @@ impl APIClient { let response = self.query_request_helper(request, true, false).await; let response = match response { Ok(r) => r, - Err(Error::Logic(status, ..)) | Err(Error::Response { status, .. }) - if status == 404 => - { + Err(e) if e.status_code() == Some(StatusCode::NOT_FOUND) => { // old server return Ok(()); } @@ -838,7 +836,7 @@ impl APIClient { status, msg: String::from_utf8_lossy(&body).to_string(), }, - true, + false, ), } } diff --git a/core/src/error.rs b/core/src/error.rs index f1153bc5..c231fd73 100644 --- a/core/src/error.rs +++ b/core/src/error.rs @@ -71,6 +71,15 @@ impl Error { pub fn with_context(self, ctx: &str) -> Self { Error::WithContext(Box::new(self), ctx.to_string()) } + + pub fn status_code(&self) -> Option { + match self { + Error::Logic(status, ..) => Some(*status), + Error::Response { status, .. } => Some(*status), + Error::WithContext(err, _) => err.status_code(), + _ => None, + } + } } impl std::fmt::Display for Error { From 0ebf502dec2f35e6529de8b9a7563fb7b694c688 Mon Sep 17 00:00:00 2001 From: Yang Xiufeng Date: Thu, 12 Dec 2024 16:17:26 +0800 Subject: [PATCH 2/2] ci: insert now return rows inserted. --- cli/tests/00-base.result | 6 ++++++ cli/tests/http/06-update.result | 1 + 2 files changed, 7 insertions(+) diff --git a/cli/tests/00-base.result b/cli/tests/00-base.result index 4bb34066..0e46b845 100644 --- a/cli/tests/00-base.result +++ b/cli/tests/00-base.result @@ -1,5 +1,8 @@ +1 +1 b 2 false "{""k"":""v""}" a 1 true [1,2] +100000 0 99999 99999 100000 1 2 @@ -11,12 +14,15 @@ with comment " a" 3 +1 NULL 3.00 3.00 0.0000000170141183460469231731687303715884105727000 -0.0000000170141183460469231731687303715884105727000 Asia/Shanghai +3 0 0.00 1 1.00 2 2.00 +2 [1,2,3] NULL (1,'ab') NULL {'k1':'v1','k2':'v2'} (2,NULL) 1 NULL 1 ab diff --git a/cli/tests/http/06-update.result b/cli/tests/http/06-update.result index 467c029b..fafccc21 100644 --- a/cli/tests/http/06-update.result +++ b/cli/tests/http/06-update.result @@ -1 +1,2 @@ 305104 +610208