@@ -64,7 +64,10 @@ func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driv
6464 if err != nil {
6565 return nil , err
6666 }
67- stmt := statement (s .stmt , args )
67+ stmt , err := statement (s .stmt , args )
68+ if err != nil {
69+ return nil , err
70+ }
6871 return query (ctx , session , stmt )
6972}
7073
@@ -74,7 +77,10 @@ func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (drive
7477 if err != nil {
7578 return nil , err
7679 }
77- stmt := statement (s .stmt , args )
80+ stmt , err := statement (s .stmt , args )
81+ if err != nil {
82+ return nil , err
83+ }
7884 return exec (ctx , session , stmt )
7985}
8086
@@ -92,7 +98,7 @@ func template(query string) string {
9298 return query
9399}
94100
95- func statement (tmpl string , args []driver.NamedValue ) string {
101+ func statement (tmpl string , args []driver.NamedValue ) ( string , error ) {
96102 stmt := tmpl
97103 for _ , arg := range args {
98104 var re * regexp.Regexp
@@ -101,10 +107,14 @@ func statement(tmpl string, args []driver.NamedValue) string {
101107 } else {
102108 re = regexp .MustCompile (fmt .Sprintf ("@p%d%s" , arg .Ordinal , `\b` ))
103109 }
104- val := fmt .Sprintf ("%v" , arg .Value )
110+ escaped , err := EscapeArg (arg )
111+ if err != nil {
112+ return "" , err
113+ }
114+ val := fmt .Sprintf ("%v" , escaped )
105115 stmt = re .ReplaceAllString (stmt , val )
106116 }
107- return stmt
117+ return stmt , nil
108118}
109119
110120func query (ctx context.Context , session * hive.Session , stmt string ) (driver.Rows , error ) {
0 commit comments