Skip to content

Commit

Permalink
Fix: table exists query
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Oct 18, 2023
1 parent f8502c4 commit e77e0a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/postgres/core/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 14 additions & 0 deletions internal/postgres/tests/general_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit e77e0a9

Please sign in to comment.