Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling NamedQuery with update/delete statement instead of select will cause connection not to be returned to pool #893

Open
adambezecny opened this issue Sep 5, 2023 · 0 comments

Comments

@adambezecny
Copy link

when calling db.NamedQuery with update/delete statement, e.g.:

query := `INSERT INTO dummy_table(league_id, subscriber_id, messaging_type) 
		  VALUES (:league_id, :subscriber_id, :messaging_type)`
if _, err := db.NamedQuery(query, s); err != nil {
      ...
    }

connection is not returned into pool leading ultimately to pool exhaustion. The correct way is to call db.NamedExec instead. The problem is API is not preventing one from calling inappropriate method (NamedQuery) with update/delete. This leads to very tricky and hard to troubleshoot errors. Could this be documented in method comments and ideally somehow prevented in runtime (e.g. trowing fatal error when calling NamedQuery with update/delete)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant