@@ -30,7 +30,6 @@ import (
3030 "github.com/go-juicedev/juice/internal/reflectlite"
3131 "github.com/go-juicedev/juice/session"
3232 "github.com/go-juicedev/juice/sql"
33- "github.com/go-juicedev/juice/sql/stmt"
3433)
3534
3635// StatementHandler defines the interface for executing SQL statements.
@@ -153,6 +152,7 @@ func buildStatementQuery(statement Statement, cfg Configuration, driver driver.D
153152// When a different query is encountered, it closes the existing statement and creates a new one.
154153type preparedStatementHandler struct {
155154 stmts * stdsql.Stmt
155+ lastQuery string
156156 middlewares MiddlewareGroup
157157 driver driver.Driver
158158 session session.Session
@@ -162,7 +162,7 @@ type preparedStatementHandler struct {
162162// getOrPrepare retrieves an existing prepared statement if the query matches,
163163// otherwise closes the current statement (if any) and creates a new one.
164164func (s * preparedStatementHandler ) getOrPrepare (ctx context.Context , query string ) (* stdsql.Stmt , error ) {
165- if s .stmts != nil && stmt . Query ( s . stmts ) == query {
165+ if s .stmts != nil && s . lastQuery == query {
166166 return s .stmts , nil
167167 }
168168 // it means the prepared statement is not what we want
@@ -174,6 +174,7 @@ func (s *preparedStatementHandler) getOrPrepare(ctx context.Context, query strin
174174 if err != nil {
175175 return nil , fmt .Errorf ("prepare statement failed: %w" , err )
176176 }
177+ s .lastQuery = query
177178 return s .stmts , nil
178179}
179180
0 commit comments