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

Migrate from util.Prepare to sqlc queries #3108

Closed
mastercactapus opened this issue Jun 20, 2023 · 2 comments
Closed

Migrate from util.Prepare to sqlc queries #3108

mastercactapus opened this issue Jun 20, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@mastercactapus
Copy link
Member

What problem would you like to solve? Please describe:
Improve the development experience by adopting sqlc as a replacement for the majority of our DB queries, which are currently using "stores" with strings directly in Go as prepared statements.

Describe the solution you'd like:
Migrate these stores from using the util.Prepare helper to using sqlc queries instead. This should make the queries more readable and maintainable.

Additional context:
This is an enhancement focused on improving the developer experience and overall project maintainability.

@mastercactapus mastercactapus added the enhancement New feature or request label Jun 20, 2023
@mastercactapus
Copy link
Member Author

mastercactapus commented Jun 20, 2023

Guidelines:

  • Create a queries.sql file in the package (if not there already)
  • Add the new .sql file to sqlc.yaml in the root
  • Update the store code to use the generated method instead of the sql.Stmt & .Scan method (e.g., gadb.New(s.db).SomeMethod() see calsub/store.go for examples)
  • Only migrate part of the store per PR for large files/packages.
  • format with pgFormatter

Example of the current state:
image

Where we want things to go:
image

@mastercactapus
Copy link
Member Author

Closing in favor of #3235, which tracks the progress of individual files across the codebase (ty @Forfold )

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

No branches or pull requests

1 participant