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

back: Remove explicit db.Prepare usage in User Service #85

Closed
daved opened this issue May 21, 2020 · 1 comment
Closed

back: Remove explicit db.Prepare usage in User Service #85

daved opened this issue May 21, 2020 · 1 comment
Assignees

Comments

@daved
Copy link
Member

daved commented May 21, 2020

Spawning from #74

@daved daved added this to the MVP (Milestone): Prototype User Service milestone Oct 22, 2020
@codegold79 codegold79 self-assigned this Dec 9, 2020
@codegold79
Copy link
Collaborator

codegold79 commented Dec 9, 2020

@coatsd and I reviewed the usage of db.Prepare in the user service query code, and we found one instance of it. It was used for inserting user_id and role_id into the join table called user_role.

According to the the tutorial section "Modifying Data and Using Transactions" in the Go Database/SQL Tutorials site, for executing statements that do not return data, such as INSERT statements, using db.Prepare is preferred.

The other option is to use Exec without db.Prepare. However, because we repeatedly use the prepared statement to insert data into user_role in a for loop, it would be beneficial to have a prepared statement use in a loop.

I'll close this issue as the db.Prepare seems to be the most appropriate way of making the aforementioned query.

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

No branches or pull requests

2 participants