Skip to content
Merged
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
8 changes: 7 additions & 1 deletion rivershared/sqlctemplate/sqlc_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,18 @@ func (r *Replacer) RunSafely(ctx context.Context, sql string, args []any) (strin

if len(container.NamedArgs) > 0 {
placeholderNum := len(args)
for arg, val := range container.NamedArgs {

// For the benefit of the test suite's output being predictable, sort
// named args before processing them.
sortedNamedArgs := maputil.Keys(container.NamedArgs)
slices.Sort(sortedNamedArgs)
for _, arg := range sortedNamedArgs {
placeholderNum++

var (
symbol = "@" + arg
symbolIndex = strings.Index(updatedSQL, symbol)
val = container.NamedArgs[arg]
)

if symbolIndex == -1 {
Expand Down