From b8c869128c9897a0c9f15a4da0a2df467bfcf811 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Mon, 21 Oct 2024 23:20:08 +0800 Subject: [PATCH 1/3] fix: empty array is valid api config --- pkg/config/api.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/config/api.go b/pkg/config/api.go index 403e290e5..cb94959a6 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -38,16 +38,10 @@ func (a *api) ToUpdatePostgrestConfigBody() v1API.UpdatePostgrestConfigBody { } // Convert Schemas to a comma-separated string - if len(a.Schemas) > 0 { - schemas := strings.Join(a.Schemas, ",") - body.DbSchema = &schemas - } + body.DbSchema = cast.Ptr(strings.Join(a.Schemas, ",")) // Convert ExtraSearchPath to a comma-separated string - if len(a.ExtraSearchPath) > 0 { - extraSearchPath := strings.Join(a.ExtraSearchPath, ",") - body.DbExtraSearchPath = &extraSearchPath - } + body.DbExtraSearchPath = cast.Ptr(strings.Join(a.ExtraSearchPath, ",")) // Convert MaxRows to int pointer if a.MaxRows > 0 { From ac91d2b7ae2f5e440189049d37c254376059c280 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Mon, 21 Oct 2024 23:56:28 +0800 Subject: [PATCH 2/3] chore: revert weird api schema update --- pkg/config/api.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/config/api.go b/pkg/config/api.go index cb94959a6..4a4007ac3 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -38,7 +38,10 @@ func (a *api) ToUpdatePostgrestConfigBody() v1API.UpdatePostgrestConfigBody { } // Convert Schemas to a comma-separated string - body.DbSchema = cast.Ptr(strings.Join(a.Schemas, ",")) + if len(a.Schemas) > 0 { + schemas := strings.Join(a.Schemas, ",") + body.DbSchema = &schemas + } // Convert ExtraSearchPath to a comma-separated string body.DbExtraSearchPath = cast.Ptr(strings.Join(a.ExtraSearchPath, ",")) From f960c27fe682f9db1d67c286c74f589c8e83e17d Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Mon, 21 Oct 2024 23:56:56 +0800 Subject: [PATCH 3/3] Update api.go --- pkg/config/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/config/api.go b/pkg/config/api.go index 4a4007ac3..51f516506 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -39,9 +39,9 @@ func (a *api) ToUpdatePostgrestConfigBody() v1API.UpdatePostgrestConfigBody { // Convert Schemas to a comma-separated string if len(a.Schemas) > 0 { - schemas := strings.Join(a.Schemas, ",") - body.DbSchema = &schemas - } + schemas := strings.Join(a.Schemas, ",") + body.DbSchema = &schemas + } // Convert ExtraSearchPath to a comma-separated string body.DbExtraSearchPath = cast.Ptr(strings.Join(a.ExtraSearchPath, ","))