@@ -27,7 +27,6 @@ import (
2727 "github.com/kyleconroy/sqlc/internal/opts"
2828 "github.com/kyleconroy/sqlc/internal/plugin"
2929 "github.com/kyleconroy/sqlc/internal/shfmt"
30- "github.com/kyleconroy/sqlc/internal/sql/ast"
3130)
3231
3332var ErrFailedChecks = errors .New ("failed checks" )
@@ -157,35 +156,6 @@ func Vet(ctx context.Context, e Env, dir, filename string, stderr io.Writer) err
157156 return nil
158157}
159158
160- // Determine if a query can be prepared based on the engine and the statement
161- // type.
162- func prepareable (sql config.SQL , raw * ast.RawStmt ) bool {
163- if sql .Engine == config .EnginePostgreSQL {
164- // TOOD: Add support for MERGE and VALUES stmts
165- switch raw .Stmt .(type ) {
166- case * ast.DeleteStmt :
167- return true
168- case * ast.InsertStmt :
169- return true
170- case * ast.SelectStmt :
171- return true
172- case * ast.UpdateStmt :
173- return true
174- default :
175- return false
176- }
177- }
178- // Almost all statements in MySQL can be prepared, so I'm just going to assume they can be
179- // https://dev.mysql.com/doc/refman/8.0/en/sql-prepared-statements.html
180- if sql .Engine == config .EngineMySQL {
181- return true
182- }
183- if sql .Engine == config .EngineSQLite {
184- return true
185- }
186- return false
187- }
188-
189159type preparer interface {
190160 Prepare (context.Context , string , string ) error
191161}
@@ -393,13 +363,8 @@ func (c *checker) checkSQL(ctx context.Context, s config.SQL) error {
393363 errored = true
394364 continue
395365 }
396- if ! prepareable (s , result .Queries [i ].RawStmt ) {
397- fmt .Fprintf (c .Stderr , "%s: %s: %s: error preparing query: %s\n " , query .Filename , query .Name , name , "query type is unpreparable" )
398- errored = true
399- continue
400- }
401- name := fmt .Sprintf ("sqlc_vet_%d_%d" , time .Now ().Unix (), i )
402- if err := prep .Prepare (ctx , name , query .Text ); err != nil {
366+ prepName := fmt .Sprintf ("sqlc_vet_%d_%d" , time .Now ().Unix (), i )
367+ if err := prep .Prepare (ctx , prepName , query .Text ); err != nil {
403368 fmt .Fprintf (c .Stderr , "%s: %s: %s: error preparing query: %s\n " , query .Filename , query .Name , name , err )
404369 errored = true
405370 continue
0 commit comments