From e77e0a9d087f15fcfe847786f66c034d864a6c82 Mon Sep 17 00:00:00 2001 From: Artem Date: Wed, 18 Oct 2023 11:40:57 +0200 Subject: [PATCH] Fix: table exists query --- internal/postgres/core/table.go | 2 +- internal/postgres/tests/general_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 internal/postgres/tests/general_test.go diff --git a/internal/postgres/core/table.go b/internal/postgres/core/table.go index c71f2f230..9e8c17bb0 100644 --- a/internal/postgres/core/table.go +++ b/internal/postgres/core/table.go @@ -120,7 +120,7 @@ type existsResponse struct { func (p *Postgres) TablesExist(ctx context.Context) bool { for _, table := range models.AllDocuments() { var exists existsResponse - err := p.DB.QueryRow(tableExistsQuery, p.schema, table).Scan(&exists) + err := p.DB.NewRaw(tableExistsQuery, p.schema, table).Scan(ctx, &exists) if !exists.Flag || err != nil { return false } diff --git a/internal/postgres/tests/general_test.go b/internal/postgres/tests/general_test.go new file mode 100644 index 000000000..18c7ccdf6 --- /dev/null +++ b/internal/postgres/tests/general_test.go @@ -0,0 +1,14 @@ +package tests + +import ( + "context" + "time" +) + +func (s *StorageTestSuite) TestTableExists() { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + exists := s.storage.TablesExist(ctx) + s.Require().True(exists) +}