Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

safesql errors out for dynamic query #21

Open
KrishKayc opened this issue Jun 7, 2021 · 0 comments
Open

safesql errors out for dynamic query #21

KrishKayc opened this issue Jun 7, 2021 · 0 comments

Comments

@KrishKayc
Copy link

KrishKayc commented Jun 7, 2021

Hi,

We have a requirement to create dynamic query along with the parameters. The query is still parameterized though.

But safesql errors out complaining the below

"Please ensure that all SQL queries you use are compile-time constants.
You should always use parameterized queries or prepared statements
instead of building queries from strings"

Code is like below:

// Dynamic query to insert all
query, params := getInsertAllQuery()

result, err := db.ExecContext(ctx, query, params...) // safesql throws error in this line.

Please let know whether this is false positive

@KrishKayc KrishKayc changed the title safesql errors for dynamic query safesql errors out for dynamic query Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant