@@ -43,7 +43,7 @@ const (
4343)
4444
4545// Middleware defines the interface for intercepting and processing SQL statement executions.
46- // It implements the interceptor pattern, allowing cross-cutting concerns like logging,
46+ // It implements the interceptor pattern, allowing cross-cutting concerns like logging,
4747// timeout management, and connection switching to be handled transparently.
4848type Middleware interface {
4949 // QueryContext intercepts and processes SELECT query executions.
@@ -94,39 +94,17 @@ func (m MiddlewareGroup) ExecContext(stmt Statement, configuration Configuration
9494 return next
9595}
9696
97- // NoopQueryContextMiddleware is a middleware that performs no operations on QueryContext.
98- // It simply passes through the query execution without any modifications or interceptions.
99- // This middleware can be useful as a base implementation or placeholder when you need
100- // a middleware that doesn't affect query execution flow.
101- type NoopQueryContextMiddleware struct {}
97+ // NoopMiddleware is a middleware that performs no operations.
98+ // It simply returns the original next handler.
99+ type NoopMiddleware struct {}
102100
103- // QueryContext implements Middleware interface.
104- // It returns the next handler in the chain without any modifications.
105- func (n NoopQueryContextMiddleware ) QueryContext (_ Statement , _ Configuration , next QueryHandler ) QueryHandler {
101+ // QueryContext implements Middleware.
102+ func (n NoopMiddleware ) QueryContext (_ Statement , _ Configuration , next QueryHandler ) QueryHandler {
106103 return next
107104}
108105
109- // ExecContext implements Middleware interface.
110- // It does nothing for ExecContext and returns the next handler as-is.
111- func (n NoopQueryContextMiddleware ) ExecContext (_ Statement , _ Configuration , next ExecHandler ) ExecHandler {
112- panic ("implement me" )
113- }
114-
115- // NoopExecContextMiddleware is a middleware that performs no operations on ExecContext.
116- // It simply passes through the execution without any modifications or interceptions.
117- // This middleware can be useful as a base implementation or placeholder when you need
118- // a middleware that doesn't affect execution flow.
119- type NoopExecContextMiddleware struct {}
120-
121- // QueryContext implements Middleware interface.
122- // It does nothing for QueryContext and returns the next handler as-is.
123- func (n NoopExecContextMiddleware ) QueryContext (_ Statement , _ Configuration , next QueryHandler ) QueryHandler {
124- panic ("implement me" )
125- }
126-
127- // ExecContext implements Middleware interface.
128- // It returns the next handler in the chain without any modifications.
129- func (n NoopExecContextMiddleware ) ExecContext (_ Statement , _ Configuration , next ExecHandler ) ExecHandler {
106+ // ExecContext implements Middleware.
107+ func (n NoopMiddleware ) ExecContext (_ Statement , _ Configuration , next ExecHandler ) ExecHandler {
130108 return next
131109}
132110
@@ -271,7 +249,7 @@ var errStructPointerOrSliceArrayRequired = errors.New(
271249// It retrieves the last insert ID from the database result and sets it to the appropriate field in the parameter object.
272250// This middleware supports both single record and batch insert operations, with configurable key properties and increment strategies.
273251type useGeneratedKeysMiddleware struct {
274- NoopQueryContextMiddleware
252+ NoopMiddleware
275253}
276254
277255// ExecContext implements Middleware.
@@ -392,7 +370,7 @@ func isInTransaction(ctx context.Context) bool {
392370// The middleware ensures that datasource switching only occurs outside of transactions
393371// to maintain data consistency and connection stability.
394372type TxSensitiveDataSourceSwitchMiddleware struct {
395- NoopExecContextMiddleware
373+ NoopMiddleware
396374}
397375
398376// selectRandomDataSource randomly selects a datasource from all available sources.
0 commit comments