Skip to content

Commit 7dada5e

Browse files
authored
ocConn: add driver.NamedValueChecker method (#44)
Allows checking for drivers that implement driver.CheckNamedValue or else fallback to the default checker.
1 parent b6f4ab8 commit 7dada5e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

driver.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var (
3333
// Compile time assertions
3434
_ driver.Driver = &ocDriver{}
3535
_ conn = &ocConn{}
36+
_ driver.NamedValueChecker = &ocConn{}
3637
_ driver.Result = &ocResult{}
3738
_ driver.Stmt = &ocStmt{}
3839
_ driver.StmtExecContext = &ocStmt{}
@@ -515,6 +516,15 @@ func (c *ocConn) BeginTx(ctx context.Context, opts driver.TxOptions) (tx driver.
515516
return ocTx{parent: tx, ctx: ctx, options: c.options}, nil
516517
}
517518

519+
func (c *ocConn) CheckNamedValue(nv *driver.NamedValue) error {
520+
nvc, ok := c.parent.(driver.NamedValueChecker)
521+
if ok {
522+
return nvc.CheckNamedValue(nv)
523+
}
524+
_, err := driver.DefaultParameterConverter.ConvertValue(nv.Value)
525+
return err
526+
}
527+
518528
// ocResult implements driver.Result
519529
type ocResult struct {
520530
parent driver.Result

0 commit comments

Comments
 (0)