Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix unsafe concurrent producer map access in client. [PR #1236](https://github.com/riverqueue/river/pull/1236).
- Fix bug in `sqltemplate` cached path in order in which named args are passed to a query (previously, the order was unstable). [PR #1243](https://github.com/riverqueue/river/pull/1243).

## [0.35.1] - 2026-04-26

Expand Down
9 changes: 8 additions & 1 deletion rivershared/sqlctemplate/sqlc_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,14 @@ func (r *Replacer) RunSafely(ctx context.Context, argPlaceholder, sql string, ar
// If all input templates were stable, the finished SQL will have been cached.
if cachedSQLOK {
if len(container.NamedArgs) > 0 {
args = append(args, maputil.Values(container.NamedArgs)...)
// Named args must be appended in sorted order to match the
// placeholder positions baked into the cached SQL during
// RunSafely's cache miss path.
sortedNamedArgs := maputil.Keys(container.NamedArgs)
slices.Sort(sortedNamedArgs)
for _, name := range sortedNamedArgs {
args = append(args, container.NamedArgs[name])
}
}
return cachedSQL, args, nil
}
Expand Down
Loading