Skip to content

Commit

Permalink
Merge pull request #13 from intelops/ext-db
Browse files Browse the repository at this point in the history
fix: query space fix for db
  • Loading branch information
Connect2naga authored Jun 8, 2024
2 parents 1d4d523 + 395fe03 commit 980434c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cypress-videos/
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
vendor/
swagger/

# Common text editors
Expand Down
4 changes: 2 additions & 2 deletions server/test/test_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const sortQuery = ` ORDER BY t.version DESC LIMIT 1`
func (r *repository) get(ctx context.Context, id id.ID) (Test, error) {
query, params := sqlutil.TenantWithPrefix(ctx, getTestSQL+" WHERE t.id = $1", "t.", id)

test, err := r.readRow(ctx, r.db.QueryRowContext(ctx, query+sortQuery, params...))
test, err := r.readRow(ctx, r.db.QueryRowContext(ctx, query+" "+sortQuery, params...))
if err != nil {
return Test{}, err
}
Expand All @@ -208,7 +208,7 @@ func (r *repository) GetTestSuiteSteps(ctx context.Context, id id.ID, version in
sortQuery := ` ORDER BY ts.step_number ASC`
query, params := sqlutil.TenantWithPrefix(ctx, getTestSQL+testMaxVersionQuery+` INNER JOIN test_suite_steps ts ON t.id = ts.test_id
WHERE ts.test_suite_id = $1 AND ts.test_suite_version = $2`, "t.", id, version)
stmt, err := r.db.Prepare(query + sortQuery)
stmt, err := r.db.Prepare(query + " "+sortQuery)
if err != nil {
return []Test{}, fmt.Errorf("prepare 2: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions server/testsuite/testsuite_run_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (td *RunRepository) GetTestSuiteRun(ctx context.Context, ID id.ID, runID in
func (td *RunRepository) GetLatestRunByTestSuiteVersion(ctx context.Context, ID id.ID, version int) (TestSuiteRun, error) {
sortQuery := " ORDER BY created_at DESC LIMIT 1"
query, params := sqlutil.Tenant(ctx, selectTestSuiteRunQuery+" WHERE test_suite_id = $1 AND test_suite_version = $2", ID, version)
stmt, err := td.db.Prepare(query + sortQuery)
stmt, err := td.db.Prepare(query +" "+sortQuery)
if err != nil {
return TestSuiteRun{}, fmt.Errorf("prepare: %w", err)
}
Expand All @@ -359,7 +359,7 @@ func (td *RunRepository) GetLatestRunByTestSuiteVersion(ctx context.Context, ID
func (td *RunRepository) GetTestSuiteRuns(ctx context.Context, ID id.ID, take, skip int32) ([]TestSuiteRun, error) {
sortQuery := " ORDER BY created_at DESC LIMIT $2 OFFSET $3"
query, params := sqlutil.Tenant(ctx, selectTestSuiteRunQuery+" WHERE test_suite_id = $1", ID.String(), take, skip)
stmt, err := td.db.Prepare(query + sortQuery)
stmt, err := td.db.Prepare(query +" "+ sortQuery)
if err != nil {
return []TestSuiteRun{}, fmt.Errorf("prepare: %w", err)
}
Expand Down

0 comments on commit 980434c

Please sign in to comment.