Skip to content

Commit

Permalink
fixed parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Dec 9, 2024
1 parent 21b6d88 commit 3d61b65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions internal/query/conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ func (c *Conn) normalize(q string, args ...driver.NamedValue) (query string, _ p
queryArgs[i] = args[i]
}

return c.parent.Bindings().RewriteQuery(q, queryArgs...)
sql, parameters, err := c.parent.Bindings().RewriteQuery(q, queryArgs...)
if err != nil {
return "", nil, xerrors.WithStackTrace(err)
}

params := params.Params(parameters)

return sql, &params, nil
}

func (c *Conn) beginTx(ctx context.Context, txOptions driver.TxOptions) (tx currentTx, finalErr error) {
Expand Down Expand Up @@ -138,7 +145,7 @@ func (c *Conn) execContext(
return nil, xerrors.WithStackTrace(err)
}

err = c.session.Exec(ctx, normalizedQuery, options.WithParameters(&params))
err = c.session.Exec(ctx, normalizedQuery, options.WithParameters(params))
if err != nil {
return nil, xerrors.WithStackTrace(err)
}
Expand Down Expand Up @@ -191,7 +198,7 @@ func (c *Conn) queryContextOther(
) (driver.Rows, error) {
res, err := c.session.Query(
ctx, queryString,
options.WithParameters(&parameters),
options.WithParameters(parameters),
)
if err != nil {
return nil, xerrors.WithStackTrace(err)
Expand All @@ -211,7 +218,7 @@ func (c *Conn) queryContextExplain(
var ast, plan string
_, err := c.session.Query(
ctx, queryString,
options.WithParameters(&parameters),
options.WithParameters(parameters),
options.WithExecMode(options.ExecModeExplain),
options.WithStatsMode(options.StatsModeNone, func(stats stats.QueryStats) {
ast = stats.QueryAST()
Expand Down
4 changes: 2 additions & 2 deletions internal/query/conn/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (tx *transaction) QueryContext(ctx context.Context, query string, args []dr
return nil, xerrors.WithStackTrace(err)
}
res, err := tx.tx.Query(ctx,
query, options.WithParameters(&parameters),
query, options.WithParameters(parameters),
)
if err != nil {
return nil, xerrors.WithStackTrace(err)
Expand Down Expand Up @@ -157,7 +157,7 @@ func (tx *transaction) ExecContext(ctx context.Context, query string, args []dri
return nil, xerrors.WithStackTrace(err)
}
err = tx.tx.Exec(ctx,
query, options.WithParameters(&parameters),
query, options.WithParameters(parameters),
)
if err != nil {
return nil, xerrors.WithStackTrace(err)
Expand Down

0 comments on commit 3d61b65

Please sign in to comment.