@@ -1654,6 +1654,11 @@ func (db *DB) prepareDC(ctx context.Context, dc *driverConn, release func(error)
1654
1654
1655
1655
// ExecContext executes a query without returning any rows.
1656
1656
// The args are for any placeholder parameters in the query.
1657
+ //
1658
+ // If any argument implements the driver.Valuer interface and
1659
+ // returns an error from its Value method, ExecContext wraps these errors
1660
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
1661
+ // to check for specific error values.
1657
1662
func (db * DB ) ExecContext (ctx context.Context , query string , args ... any ) (Result , error ) {
1658
1663
var res Result
1659
1664
var err error
@@ -1669,6 +1674,11 @@ func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (Resul
1669
1674
// Exec executes a query without returning any rows.
1670
1675
// The args are for any placeholder parameters in the query.
1671
1676
//
1677
+ // If any argument implements the driver.Valuer interface and
1678
+ // returns an error from its Value method, Exec wraps these errors
1679
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
1680
+ // to check for specific error values.
1681
+ //
1672
1682
// Exec uses [context.Background] internally; to specify the context, use
1673
1683
// [DB.ExecContext].
1674
1684
func (db * DB ) Exec (query string , args ... any ) (Result , error ) {
@@ -1724,6 +1734,11 @@ func (db *DB) execDC(ctx context.Context, dc *driverConn, release func(error), q
1724
1734
1725
1735
// QueryContext executes a query that returns rows, typically a SELECT.
1726
1736
// The args are for any placeholder parameters in the query.
1737
+ //
1738
+ // If any argument implements the driver.Valuer interface and
1739
+ // returns an error from its Value method, QueryContext wraps these errors
1740
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
1741
+ // to check for specific error values.
1727
1742
func (db * DB ) QueryContext (ctx context.Context , query string , args ... any ) (* Rows , error ) {
1728
1743
var rows * Rows
1729
1744
var err error
@@ -1739,6 +1754,11 @@ func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (*Row
1739
1754
// Query executes a query that returns rows, typically a SELECT.
1740
1755
// The args are for any placeholder parameters in the query.
1741
1756
//
1757
+ // If any argument implements the driver.Valuer interface and
1758
+ // returns an error from its Value method, Query wraps these errors
1759
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
1760
+ // to check for specific error values.
1761
+ //
1742
1762
// Query uses [context.Background] internally; to specify the context, use
1743
1763
// [DB.QueryContext].
1744
1764
func (db * DB ) Query (query string , args ... any ) (* Rows , error ) {
@@ -1828,6 +1848,12 @@ func (db *DB) queryDC(ctx, txctx context.Context, dc *driverConn, releaseConn fu
1828
1848
// If the query selects no rows, the [*Row.Scan] will return [ErrNoRows].
1829
1849
// Otherwise, [*Row.Scan] scans the first selected row and discards
1830
1850
// the rest.
1851
+ //
1852
+ // if any argument implements the driver.Valuer interface and
1853
+ // returns an error from its Value method, this error will be captured and
1854
+ // wrapped using fmt.Errorf and the %w verb when it is processed during the call to Scan.
1855
+ // This approach allows callers to use errors.Is in the subsequent call to [*Row.Scan]
1856
+ // to check for specific error values, ensuring precise error handling.
1831
1857
func (db * DB ) QueryRowContext (ctx context.Context , query string , args ... any ) * Row {
1832
1858
rows , err := db .QueryContext (ctx , query , args ... )
1833
1859
return & Row {rows : rows , err : err }
@@ -1840,6 +1866,12 @@ func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) *R
1840
1866
// Otherwise, [*Row.Scan] scans the first selected row and discards
1841
1867
// the rest.
1842
1868
//
1869
+ // if any argument implements the driver.Valuer interface and
1870
+ // returns an error from its Value method, this error will be captured and
1871
+ // wrapped using fmt.Errorf and the %w verb when it is processed during the call to Scan.
1872
+ // This approach allows callers to use errors.Is in the subsequent call to [*Row.Scan]
1873
+ // to check for specific error values, ensuring precise error handling.
1874
+ //
1843
1875
// QueryRow uses [context.Background] internally; to specify the context, use
1844
1876
// [DB.QueryRowContext].
1845
1877
func (db * DB ) QueryRow (query string , args ... any ) * Row {
@@ -2009,6 +2041,11 @@ func (c *Conn) PingContext(ctx context.Context) error {
2009
2041
2010
2042
// ExecContext executes a query without returning any rows.
2011
2043
// The args are for any placeholder parameters in the query.
2044
+ //
2045
+ // If any argument implements the driver.Valuer interface and
2046
+ // returns an error from its Value method, ExecContext wraps these errors
2047
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2048
+ // to check for specific error values.
2012
2049
func (c * Conn ) ExecContext (ctx context.Context , query string , args ... any ) (Result , error ) {
2013
2050
dc , release , err := c .grabConn (ctx )
2014
2051
if err != nil {
@@ -2019,6 +2056,11 @@ func (c *Conn) ExecContext(ctx context.Context, query string, args ...any) (Resu
2019
2056
2020
2057
// QueryContext executes a query that returns rows, typically a SELECT.
2021
2058
// The args are for any placeholder parameters in the query.
2059
+ //
2060
+ // If any argument implements the driver.Valuer interface and
2061
+ // returns an error from its Value method, QueryContext wraps these errors
2062
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2063
+ // to check for specific error values.
2022
2064
func (c * Conn ) QueryContext (ctx context.Context , query string , args ... any ) (* Rows , error ) {
2023
2065
dc , release , err := c .grabConn (ctx )
2024
2066
if err != nil {
@@ -2033,6 +2075,12 @@ func (c *Conn) QueryContext(ctx context.Context, query string, args ...any) (*Ro
2033
2075
// If the query selects no rows, the [*Row.Scan] will return [ErrNoRows].
2034
2076
// Otherwise, the [*Row.Scan] scans the first selected row and discards
2035
2077
// the rest.
2078
+ //
2079
+ // if any argument implements the driver.Valuer interface and
2080
+ // returns an error from its Value method, this error will be captured and
2081
+ // wrapped using fmt.Errorf and the %w verb when it is processed during the call to Scan.
2082
+ // This approach allows callers to use errors.Is in the subsequent call to [*Row.Scan]
2083
+ // to check for specific error values, ensuring precise error handling.
2036
2084
func (c * Conn ) QueryRowContext (ctx context.Context , query string , args ... any ) * Row {
2037
2085
rows , err := c .QueryContext (ctx , query , args ... )
2038
2086
return & Row {rows : rows , err : err }
@@ -2498,6 +2546,11 @@ func (tx *Tx) Stmt(stmt *Stmt) *Stmt {
2498
2546
2499
2547
// ExecContext executes a query that doesn't return rows.
2500
2548
// For example: an INSERT and UPDATE.
2549
+ //
2550
+ // If any argument implements the driver.Valuer interface and
2551
+ // returns an error from its Value method, ExecContext wraps these errors
2552
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2553
+ // to check for specific error values.
2501
2554
func (tx * Tx ) ExecContext (ctx context.Context , query string , args ... any ) (Result , error ) {
2502
2555
dc , release , err := tx .grabConn (ctx )
2503
2556
if err != nil {
@@ -2509,13 +2562,23 @@ func (tx *Tx) ExecContext(ctx context.Context, query string, args ...any) (Resul
2509
2562
// Exec executes a query that doesn't return rows.
2510
2563
// For example: an INSERT and UPDATE.
2511
2564
//
2565
+ // If any argument implements the driver.Valuer interface and
2566
+ // returns an error from its Value method, Exec wraps these errors
2567
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2568
+ // to check for specific error values.
2569
+ //
2512
2570
// Exec uses [context.Background] internally; to specify the context, use
2513
2571
// [Tx.ExecContext].
2514
2572
func (tx * Tx ) Exec (query string , args ... any ) (Result , error ) {
2515
2573
return tx .ExecContext (context .Background (), query , args ... )
2516
2574
}
2517
2575
2518
2576
// QueryContext executes a query that returns rows, typically a SELECT.
2577
+ //
2578
+ // If any argument implements the driver.Valuer interface and
2579
+ // returns an error from its Value method, QueryContext wraps these errors
2580
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2581
+ // to check for specific error values.
2519
2582
func (tx * Tx ) QueryContext (ctx context.Context , query string , args ... any ) (* Rows , error ) {
2520
2583
dc , release , err := tx .grabConn (ctx )
2521
2584
if err != nil {
@@ -2529,6 +2592,11 @@ func (tx *Tx) QueryContext(ctx context.Context, query string, args ...any) (*Row
2529
2592
//
2530
2593
// Query uses [context.Background] internally; to specify the context, use
2531
2594
// [Tx.QueryContext].
2595
+ //
2596
+ // If any argument implements the driver.Valuer interface and
2597
+ // returns an error from its Value method, Query wraps these errors
2598
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2599
+ // to check for specific error values.
2532
2600
func (tx * Tx ) Query (query string , args ... any ) (* Rows , error ) {
2533
2601
return tx .QueryContext (context .Background (), query , args ... )
2534
2602
}
@@ -2539,6 +2607,12 @@ func (tx *Tx) Query(query string, args ...any) (*Rows, error) {
2539
2607
// If the query selects no rows, the [*Row.Scan] will return [ErrNoRows].
2540
2608
// Otherwise, the [*Row.Scan] scans the first selected row and discards
2541
2609
// the rest.
2610
+ //
2611
+ // if any argument implements the driver.Valuer interface and
2612
+ // returns an error from its Value method, this error will be captured and
2613
+ // wrapped using fmt.Errorf and the %w verb when it is processed during the call to Scan.
2614
+ // This approach allows callers to use errors.Is in the subsequent call to [*Row.Scan]
2615
+ // to check for specific error values, ensuring precise error handling.
2542
2616
func (tx * Tx ) QueryRowContext (ctx context.Context , query string , args ... any ) * Row {
2543
2617
rows , err := tx .QueryContext (ctx , query , args ... )
2544
2618
return & Row {rows : rows , err : err }
@@ -2551,6 +2625,12 @@ func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...any) *R
2551
2625
// Otherwise, the [*Row.Scan] scans the first selected row and discards
2552
2626
// the rest.
2553
2627
//
2628
+ // if any argument implements the driver.Valuer interface and
2629
+ // returns an error from its Value method, this error will be captured and
2630
+ // wrapped using fmt.Errorf and the %w verb when it is processed during the call to Scan.
2631
+ // This approach allows callers to use errors.Is in the subsequent call to [*Row.Scan]
2632
+ // to check for specific error values, ensuring precise error handling.
2633
+ //
2554
2634
// QueryRow uses [context.Background] internally; to specify the context, use
2555
2635
// [Tx.QueryRowContext].
2556
2636
func (tx * Tx ) QueryRow (query string , args ... any ) * Row {
@@ -2630,6 +2710,11 @@ type Stmt struct {
2630
2710
2631
2711
// ExecContext executes a prepared statement with the given arguments and
2632
2712
// returns a [Result] summarizing the effect of the statement.
2713
+ //
2714
+ // If any argument implements the driver.Valuer interface and
2715
+ // returns an error from its Value method, ExecContext wraps these errors
2716
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2717
+ // to check for specific error values.
2633
2718
func (s * Stmt ) ExecContext (ctx context.Context , args ... any ) (Result , error ) {
2634
2719
s .closemu .RLock ()
2635
2720
defer s .closemu .RUnlock ()
@@ -2652,6 +2737,11 @@ func (s *Stmt) ExecContext(ctx context.Context, args ...any) (Result, error) {
2652
2737
// Exec executes a prepared statement with the given arguments and
2653
2738
// returns a [Result] summarizing the effect of the statement.
2654
2739
//
2740
+ // If any argument implements the driver.Valuer interface and
2741
+ // returns an error from its Value method, Exec wraps these errors
2742
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2743
+ // to check for specific error values.
2744
+ //
2655
2745
// Exec uses [context.Background] internally; to specify the context, use
2656
2746
// [Stmt.ExecContext].
2657
2747
func (s * Stmt ) Exec (args ... any ) (Result , error ) {
@@ -2770,6 +2860,11 @@ func (s *Stmt) prepareOnConnLocked(ctx context.Context, dc *driverConn) (*driver
2770
2860
2771
2861
// QueryContext executes a prepared query statement with the given arguments
2772
2862
// and returns the query results as a [*Rows].
2863
+ //
2864
+ // If any argument implements the driver.Valuer interface and
2865
+ // returns an error from its Value method, QueryContext wraps these errors
2866
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2867
+ // to check for specific error values.
2773
2868
func (s * Stmt ) QueryContext (ctx context.Context , args ... any ) (* Rows , error ) {
2774
2869
s .closemu .RLock ()
2775
2870
defer s .closemu .RUnlock ()
@@ -2820,6 +2915,11 @@ func (s *Stmt) QueryContext(ctx context.Context, args ...any) (*Rows, error) {
2820
2915
// Query executes a prepared query statement with the given arguments
2821
2916
// and returns the query results as a *Rows.
2822
2917
//
2918
+ // If any argument implements the driver.Valuer interface and
2919
+ // returns an error from its Value method, Query wraps these errors
2920
+ // using fmt.Errorf and %w verb. This allows callers to use errors.Is
2921
+ // to check for specific error values.
2922
+ //
2823
2923
// Query uses [context.Background] internally; to specify the context, use
2824
2924
// [Stmt.QueryContext].
2825
2925
func (s * Stmt ) Query (args ... any ) (* Rows , error ) {
@@ -2842,6 +2942,12 @@ func rowsiFromStatement(ctx context.Context, ci driver.Conn, ds *driverStmt, arg
2842
2942
// If the query selects no rows, the [*Row.Scan] will return [ErrNoRows].
2843
2943
// Otherwise, the [*Row.Scan] scans the first selected row and discards
2844
2944
// the rest.
2945
+ //
2946
+ // if any argument implements the driver.Valuer interface and
2947
+ // returns an error from its Value method, this error will be captured and
2948
+ // wrapped using fmt.Errorf and the %w verb when it is processed during the call to Scan.
2949
+ // This approach allows callers to use errors.Is in the subsequent call to [*Row.Scan]
2950
+ // to check for specific error values, ensuring precise error handling.
2845
2951
func (s * Stmt ) QueryRowContext (ctx context.Context , args ... any ) * Row {
2846
2952
rows , err := s .QueryContext (ctx , args ... )
2847
2953
if err != nil {
@@ -2857,6 +2963,12 @@ func (s *Stmt) QueryRowContext(ctx context.Context, args ...any) *Row {
2857
2963
// Otherwise, the [*Row.Scan] scans the first selected row and discards
2858
2964
// the rest.
2859
2965
//
2966
+ // if any argument implements the driver.Valuer interface and
2967
+ // returns an error from its Value method, this error will be captured and
2968
+ // wrapped using fmt.Errorf and the %w verb when it is processed during the call to Scan.
2969
+ // This approach allows callers to use errors.Is in the subsequent call to [*Row.Scan]
2970
+ // to check for specific error values, ensuring precise error handling.
2971
+ //
2860
2972
// Example usage:
2861
2973
//
2862
2974
// var name string
0 commit comments