@@ -466,23 +466,7 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
466466 return ;
467467 }
468468 const types : { name : string , type : string } [ ] =
469- stmt . getColumns ( ) . map ( ( column ) => {
470- const type = {
471- name : column . getName ( ) . toLowerCase ( ) ,
472- type : '' ,
473- } ;
474- if ( column . isNumber ( ) ) {
475- // @ts -ignore
476- if ( column . getPrecision ( ) === 0 ) {
477- type . type = 'int' ;
478- } else {
479- type . type = 'decimal' ;
480- }
481- } else {
482- type . type = this . toGenericType ( column . getType ( ) ) ;
483- }
484- return type ;
485- } ) ;
469+ this . getTypes ( stmt ) ;
486470 resolve ( types ) ;
487471 } ,
488472 } ) ) ;
@@ -718,23 +702,7 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
718702 }
719703 const hydrationMap = this . generateHydrationMap ( stmt . getColumns ( ) ) ;
720704 const types : { name : string , type : string } [ ] =
721- stmt . getColumns ( ) . map ( ( column ) => {
722- const type = {
723- name : column . getName ( ) . toLowerCase ( ) ,
724- type : '' ,
725- } ;
726- if ( column . isNumber ( ) ) {
727- // @ts -ignore
728- if ( column . getPrecision ( ) === 0 ) {
729- type . type = 'int' ;
730- } else {
731- type . type = 'decimal' ;
732- }
733- } else {
734- type . type = this . toGenericType ( column . getType ( ) ) ;
735- }
736- return type ;
737- } ) ;
705+ this . getTypes ( stmt ) ;
738706 if ( rows && rows . length && Object . keys ( hydrationMap ) . length ) {
739707 for ( const row of rows ) {
740708 for ( const [ field , toValue ] of Object . entries ( hydrationMap ) ) {
@@ -779,23 +747,7 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
779747 }
780748 } ) ) ;
781749 const types : { name : string , type : string } [ ] =
782- stmt . getColumns ( ) . map ( ( column ) => {
783- const type = {
784- name : column . getName ( ) . toLowerCase ( ) ,
785- type : '' ,
786- } ;
787- if ( column . isNumber ( ) ) {
788- // @ts -ignore
789- if ( column . getPrecision ( ) === 0 ) {
790- type . type = 'int' ;
791- } else {
792- type . type = 'decimal' ;
793- }
794- } else {
795- type . type = this . toGenericType ( column . getType ( ) ) ;
796- }
797- return type ;
798- } ) ;
750+ this . getTypes ( stmt ) ;
799751 const hydrationMap = this . generateHydrationMap ( stmt . getColumns ( ) ) ;
800752 if ( Object . keys ( hydrationMap ) . length ) {
801753 const rowStream = new HydrationStream ( hydrationMap ) ;
@@ -817,6 +769,26 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
817769 } ;
818770 }
819771
772+ private getTypes ( stmt : Statement ) {
773+ return stmt . getColumns ( ) . map ( ( column ) => {
774+ const type = {
775+ name : column . getName ( ) . toLowerCase ( ) ,
776+ type : '' ,
777+ } ;
778+ if ( column . isNumber ( ) ) {
779+ // @ts -ignore
780+ if ( column . getScale ( ) === 0 ) {
781+ type . type = 'int' ;
782+ } else {
783+ type . type = 'decimal' ;
784+ }
785+ } else {
786+ type . type = this . toGenericType ( column . getType ( ) ) ;
787+ }
788+ return type ;
789+ } ) ;
790+ }
791+
820792 protected generateHydrationMap ( columns : Column [ ] ) : HydrationMap {
821793 const hydrationMap : Record < string , any > = { } ;
822794
0 commit comments