@@ -19,18 +19,6 @@ import (
19
19
20
20
var ErrUnsupportedStatementType = errors .New ("parseQuery: unsupported statement type" )
21
21
22
- func rewriteNumberedParameters (refs []paramRef , raw * ast.RawStmt , sql string ) ([]source.Edit , error ) {
23
- edits := make ([]source.Edit , len (refs ))
24
- for i , ref := range refs {
25
- edits [i ] = source.Edit {
26
- Location : ref .ref .Location - raw .StmtLocation ,
27
- Old : fmt .Sprintf ("$%d" , ref .ref .Number ),
28
- New : "?" ,
29
- }
30
- }
31
- return edits , nil
32
- }
33
-
34
22
func (c * Compiler ) parseQuery (stmt ast.Node , src string , o opts.Parser ) (* Query , error ) {
35
23
if o .Debug .DumpAST {
36
24
debug .Dump (stmt )
@@ -90,19 +78,14 @@ func (c *Compiler) parseQuery(stmt ast.Node, src string, o opts.Parser) (*Query,
90
78
if err != nil {
91
79
return nil , err
92
80
}
93
- if o .UsePositionalParameters {
94
- edits , err = rewriteNumberedParameters (refs , raw , rawSQL )
95
- if err != nil {
96
- return nil , err
97
- }
81
+
82
+ refs = uniqueParamRefs (refs , dollar )
83
+ if c .conf .Engine == config .EngineMySQL || ! dollar {
84
+ sort .Slice (refs , func (i , j int ) bool { return refs [i ].ref .Location < refs [j ].ref .Location })
98
85
} else {
99
- refs = uniqueParamRefs (refs , dollar )
100
- if c .conf .Engine == config .EngineMySQL || ! dollar {
101
- sort .Slice (refs , func (i , j int ) bool { return refs [i ].ref .Location < refs [j ].ref .Location })
102
- } else {
103
- sort .Slice (refs , func (i , j int ) bool { return refs [i ].ref .Number < refs [j ].ref .Number })
104
- }
86
+ sort .Slice (refs , func (i , j int ) bool { return refs [i ].ref .Number < refs [j ].ref .Number })
105
87
}
88
+
106
89
qc , err := buildQueryCatalog (c .catalog , raw .Stmt )
107
90
if err != nil {
108
91
return nil , err
0 commit comments