8000 Implement job list with sqlc using templates by brandur · Pull Request #795 · riverqueue/river · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Implement job list with sqlc using templates #795

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

Merged
merged 1 commit into from
Mar 9, 2025

Conversation

brandur
Copy link
Contributor
@brandur brandur commented Mar 8, 2025

Here, reimplement the job list API's internals using sqlc using the new
sqlc template system introduced in #794. Admittedly this one isn't quite
as big of a win as we expect the templating to be in some cases, but it
gets rid of a case of SQL code in a raw string, and lets us drop the
JobListFields driver interface function.

We don't add tests because the APIs are relatively well tested already,
but make some small modifications to the driver JobList test cases so
they're a little more thorough.

brandur added a commit that referenced this pull request Mar 8, 2025
…ting

Here, fix an intermittent test [1] that's come up _already_ since #795
was merged in. This is a problem that gets me a lot, which is that map
sorting in Go is not guaranteed, despite in tests small maps often
coming out in the order that you're looking for so you don't notice a
problem until later.

Here, when processing named args in a template, walk through them in
alphabetical order. This has no meaningful effect on the rendered SQL,
but provides stability for the test suite.

[1] https://github.com/riverqueue/river/actions/runs/13734150171/job/38415749775?pr=795
brandur added a commit that referenced this pull request Mar 9, 2025
…ting (#796)

Here, fix an intermittent test [1] that's come up _already_ since #795
was merged in. This is a problem that gets me a lot, which is that map
sorting in Go is not guaranteed, despite in tests small maps often
coming out in the order that you're looking for so you don't notice a
problem until later.

Here, when processing named args in a template, walk through them in
alphabetical order. This has no meaningful effect on the rendered SQL,
but provides stability for the test suite.

[1] https://github.com/riverqueue/river/actions/runs/13734150171/job/38415749775?pr=795
Here, reimplement the job list API's internals using sqlc using the new
sqlc template system introduced in #794. Admittedly this one isn't quite
as big of a win as we expect the templating to be in some cases, but it
gets rid of a case of SQL code in a raw string, and lets us drop the
`JobListFields` driver interface function.

We don't add tests because the APIs are relatively well tested already,
but make some small modifications to the driver `JobList` test cases so
they're a little more thorough.
@brandur brandur force-pushed the brandur-job-list-sqlc branch from f7a8c28 to 1a4d0de Compare March 9, 2025 01:00
@brandur brandur merged commit 937b493 into master Mar 9, 2025
10 checks passed
@brandur brandur deleted the brandur-job-list-sqlc branch March 9, 2025 01:12
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

Successfully merging this pull request may close these issues.

2 participants
0