Skip to content

Commit

Permalink
Make the SQL queries static
Browse files Browse the repository at this point in the history
This simplifies the logic and makes it clearer what query is being made
when reading the code.

Signed-off-by: mprahl <[email protected]>
  • Loading branch information
mprahl committed Jan 3, 2024
1 parent 8a0fbb0 commit ff3befc
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 164 deletions.
2 changes: 1 addition & 1 deletion controllers/complianceeventsapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func getPolicyForeignKey(ctx context.Context, db *sql.DB, pol Policy) (int, erro

if pol.Spec == "" {
row := db.QueryRowContext(
ctx, fmt.Sprintf("SELECT spec FROM %s WHERE spec_hash = $1 LIMIT 1", policyTableName), pol.SpecHash,
ctx, "SELECT spec FROM policies WHERE spec_hash=$1 LIMIT 1", pol.SpecHash,
)
if row.Err() != nil {
return 0, fmt.Errorf("could not determine the spec from the provided spec hash: %w", row.Err())
Expand Down
Loading

0 comments on commit ff3befc

Please sign in to comment.