@@ -290,7 +290,7 @@ describe("Stmt2 decimal bind behavior (mock)", () => {
290290 ) ;
291291 } ) ;
292292
293- test ( "bind should not mutate caller params so full-binding params can be reused " , async ( ) => {
293+ test ( "bind should normalize full-binding decimal params in place " , async ( ) => {
294294 const fields = createInsertFields ( ) ;
295295 const stmt = createBareStmt ( fields , true ) ;
296296 const params = new Stmt2BindParams ( fields . length , 13 , fields ) ;
@@ -303,17 +303,11 @@ describe("Stmt2 decimal bind behavior (mock)", () => {
303303
304304 await stmt . bind ( params ) ;
305305
306- expect ( params . _fieldParams ?. [ 3 ] . columnType ) . toBe ( TDengineTypeCode . DECIMAL ) ;
306+ expect ( params . _fieldParams ?. [ 3 ] . columnType ) . toBe ( TDengineTypeCode . DECIMAL64 ) ;
307307
308- params . setVarchar ( [ "d0" ] ) ;
309- params . setVarchar ( [ "beijing" ] ) ;
310- params . setInt ( [ 1 ] ) ;
311- expect ( ( ) => {
312- params . setDecimal ( [ "223.456700" ] ) ;
313- } ) . not . toThrow ( ) ;
314- params . setInt ( [ 11 ] ) ;
315-
316- expect ( params . _fieldParams ?. [ 3 ] . params . length ) . toBe ( 2 ) ;
308+ const tableInfo = stmt . _stmtTableInfo . get ( "d0" ) ;
309+ const colParams = tableInfo ?. getParams ( ) ;
310+ expect ( colParams ?. _fieldParams ?. [ 0 ] . columnType ) . toBe ( TDengineTypeCode . DECIMAL64 ) ;
317311 } ) ;
318312
319313 test ( "bind should override DECIMAL to real column decimal type in non-full-binding insert" , async ( ) => {
@@ -327,6 +321,7 @@ describe("Stmt2 decimal bind behavior (mock)", () => {
327321 await stmt . bind ( params ) ;
328322
329323 const bindParams = stmt . _currentTableInfo . getParams ( ) ;
324+ expect ( bindParams ) . toBe ( params ) ;
330325 expect ( bindParams ?. _fieldParams ?. [ 0 ] . columnType ) . toBe (
331326 TDengineTypeCode . DECIMAL64
332327 ) ;
@@ -335,6 +330,32 @@ describe("Stmt2 decimal bind behavior (mock)", () => {
335330 ) ;
336331 } ) ;
337332
333+ test ( "bind should still allow setDecimal after in-place normalization" , async ( ) => {
334+ const fields = createInsertFields ( ) ;
335+ const stmt = createBareStmt ( fields , true ) ;
336+ const params = new Stmt2BindParams ( fields . length , 13 , fields ) ;
337+
338+ params . setVarchar ( [ "d0" ] ) ;
339+ params . setVarchar ( [ "beijing" ] ) ;
340+ params . setInt ( [ 1 ] ) ;
341+ params . setDecimal ( [ "123.456700" ] ) ;
342+ params . setInt ( [ 10 ] ) ;
343+
344+ await stmt . bind ( params ) ;
345+
346+ expect ( params . _fieldParams ?. [ 3 ] . columnType ) . toBe ( TDengineTypeCode . DECIMAL64 ) ;
347+
348+ params . setVarchar ( [ "d0" ] ) ;
349+ params . setVarchar ( [ "beijing" ] ) ;
350+ params . setInt ( [ 1 ] ) ;
351+ expect ( ( ) => {
352+ params . setDecimal ( [ "223.456700" ] ) ;
353+ } ) . not . toThrow ( ) ;
354+ params . setInt ( [ 11 ] ) ;
355+
356+ expect ( params . _fieldParams ?. [ 3 ] . params . length ) . toBe ( 2 ) ;
357+ } ) ;
358+
338359 test ( "query mode should keep DECIMAL default type" , async ( ) => {
339360 const fields = createInsertFields ( ) ;
340361 const stmt = createBareStmt ( fields , false ) ;
0 commit comments