@@ -119,6 +119,7 @@ func (c *conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, e
119119 }
120120 return & stmt {
121121 conn : c ,
122+ tx : c .currentTx ,
122123 params : internal .Params (s ),
123124 query : query ,
124125 }, nil
@@ -153,12 +154,22 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name
153154 return nil , errClosedConn
154155 }
155156 m := queryModeFromContext (ctx , c .defaultQueryMode )
156- if c .currentTx != nil && m == DataQueryMode {
157+ if c .currentTx != nil {
158+ if m != DataQueryMode {
159+ return nil , xerrors .WithStackTrace (
160+ fmt .Errorf ("query mode `%s` not supported with transaction" , m .String ()),
161+ )
162+ }
157163 return c .currentTx .ExecContext (ctx , query , args )
158164 }
159165 switch m {
160166 case DataQueryMode :
161- _ , res , err := c .session .Execute (ctx , txControl (ctx , c .defaultTxControl ), query , toQueryParams (args ))
167+ _ , res , err := c .session .Execute (ctx ,
168+ txControl (ctx , c .defaultTxControl ),
169+ query ,
170+ toQueryParams (args ),
171+ dataQueryOptions (ctx )... ,
172+ )
162173 if err != nil {
163174 return nil , c .checkClosed (err )
164175 }
@@ -167,7 +178,7 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name
167178 }
168179 return c , nil
169180 case SchemeQueryMode :
170- err := c .session .ExecuteSchemeQuery (ctx , query , toSchemeOptions ( args ) ... )
181+ err := c .session .ExecuteSchemeQuery (ctx , query )
171182 if err != nil {
172183 return nil , c .checkClosed (err )
173184 }
@@ -188,12 +199,22 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam
188199 return nil , errClosedConn
189200 }
190201 m := queryModeFromContext (ctx , c .defaultQueryMode )
191- if c .currentTx != nil && m == DataQueryMode {
202+ if c .currentTx != nil {
203+ if m != DataQueryMode {
204+ return nil , xerrors .WithStackTrace (
205+ fmt .Errorf ("query mode `%s` not supported with transaction" , m .String ()),
206+ )
207+ }
192208 return c .currentTx .QueryContext (ctx , query , args )
193209 }
194210 switch m {
195211 case DataQueryMode :
196- _ , res , err := c .session .Execute (ctx , txControl (ctx , c .defaultTxControl ), query , toQueryParams (args ))
212+ _ , res , err := c .session .Execute (ctx ,
213+ txControl (ctx , c .defaultTxControl ),
214+ query ,
215+ toQueryParams (args ),
216+ dataQueryOptions (ctx )... ,
217+ )
197218 if err != nil {
198219 return nil , c .checkClosed (err )
199220 }
@@ -204,7 +225,11 @@ func (c *conn) QueryContext(ctx context.Context, query string, args []driver.Nam
204225 result : res ,
205226 }, nil
206227 case ScanQueryMode :
207- res , err := c .session .StreamExecuteScanQuery (ctx , query , toQueryParams (args ), scanQueryOptions (ctx )... )
228+ res , err := c .session .StreamExecuteScanQuery (ctx ,
229+ query ,
230+ toQueryParams (args ),
231+ scanQueryOptions (ctx )... ,
232+ )
208233 if err != nil {
209234 return nil , c .checkClosed (err )
210235 }
0 commit comments