File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -66,14 +66,12 @@ let getTypeByValue = function (value) {
66
66
return TYPES . NVarChar
67
67
68
68
case 'number' :
69
- for ( item of Array . from ( map ) ) {
70
- if ( item . js === Number ) {
71
- return item . sql
72
- }
69
+ if ( value % 1 === 0 ) {
70
+ return TYPES . Int
71
+ } else {
72
+ return TYPES . Float
73
73
}
74
74
75
- return TYPES . Int
76
-
77
75
case 'boolean' :
78
76
for ( item of Array . from ( map ) ) {
79
77
if ( item . js === Boolean ) {
@@ -1558,7 +1556,8 @@ module.exports = {
1558
1556
ISOLATION_LEVEL ,
1559
1557
TYPES ,
1560
1558
MAX : 65535 , // (1 << 16) - 1
1561
- map
1559
+ map,
1560
+ getTypeByValue
1562
1561
}
1563
1562
}
1564
1563
Original file line number Diff line number Diff line change @@ -173,4 +173,9 @@ describe('Unit', () => {
173
173
done ( )
174
174
} )
175
175
} )
176
+
177
+ it ( 'infer type by value' , ( ) => {
178
+ assert . strictEqual ( sql . Int , sql . getTypeByValue ( 23 ) )
179
+ assert . strictEqual ( sql . Float , sql . getTypeByValue ( 1.23 ) )
180
+ } )
176
181
} )
You can’t perform that action at this time.
0 commit comments