@@ -802,7 +802,7 @@ Agent.prototype._update = function(item) {
802802} ;
803803
804804Agent . prototype . _select = function ( item ) {
805- return { name : item . name , query : item . condition . toQuery ( item . query ) + item . condition . toString ( this . id ) , params : null , first : item . condition . _take === 1 } ;
805+ return { name : item . name , query : item . condition . toQuery ( item . query ) + item . condition . toString ( this . id ) , params : null , first : item . condition . _take === 1 , datatype : item . datatype } ;
806806} ;
807807
808808Agent . prototype . _delete = function ( item ) {
@@ -927,7 +927,7 @@ Agent.prototype.count = function(name, table, column) {
927927 column = '*' ;
928928
929929 var condition = new SqlBuilder ( ) ;
930- self . command . push ( { type : 'query' , query : 'SELECT COUNT(' + column + ') as sqlagentcolumn FROM ' + table , name : name , condition : condition , first : true , column : 'sqlagentcolumn' } ) ;
930+ self . command . push ( { type : 'query' , query : 'SELECT COUNT(' + column + ') as sqlagentcolumn FROM ' + table , name : name , condition : condition , first : true , column : 'sqlagentcolumn' , datatype : 1 } ) ;
931931 return condition ;
932932} ;
933933
@@ -939,7 +939,7 @@ Agent.prototype.max = function(name, table, column) {
939939 }
940940
941941 var condition = new SqlBuilder ( ) ;
942- self . command . push ( { type : 'query' , query : 'SELECT MAX(' + column + ') as sqlagentcolumn FROM ' + table , name : name , condition : condition , first : true , column : 'sqlagentcolumn' } ) ;
942+ self . command . push ( { type : 'query' , query : 'SELECT MAX(' + column + ') as sqlagentcolumn FROM ' + table , name : name , condition : condition , first : true , column : 'sqlagentcolumn' , datatype : 1 } ) ;
943943 return condition ;
944944} ;
945945
@@ -951,7 +951,7 @@ Agent.prototype.min = function(name, table, column) {
951951 }
952952
953953 var condition = new SqlBuilder ( ) ;
954- self . command . push ( { type : 'query' , query : 'SELECT MAX(' + column + ') as sqlagentcolumn FROM ' + table , name : name , condition : condition , first : true , column : 'sqlagentcolumn' } ) ;
954+ self . command . push ( { type : 'query' , query : 'SELECT MAX(' + column + ') as sqlagentcolumn FROM ' + table , name : name , condition : condition , first : true , column : 'sqlagentcolumn' , datatype : 1 } ) ;
955955 return condition ;
956956} ;
957957
@@ -963,7 +963,7 @@ Agent.prototype.avg = function(name, table, column) {
963963 }
964964
965965 var condition = new SqlBuilder ( ) ;
966- self . command . push ( { type : 'query' , query : 'SELECT AVG(' + column + ') as sqlagentcolumn FROM ' + table , name : name , condition : condition , first : true , column : 'sqlagentcolumn' } ) ;
966+ self . command . push ( { type : 'query' , query : 'SELECT AVG(' + column + ') as sqlagentcolumn FROM ' + table , name : name , condition : condition , first : true , column : 'sqlagentcolumn' , datatype : 1 } ) ;
967967 return condition ;
968968} ;
969969
@@ -1220,7 +1220,7 @@ Agent.prototype._prepare = function(callback) {
12201220
12211221 if ( current . first && current . column ) {
12221222 if ( rows . length > 0 )
1223- self . results [ current . name ] = current . column === 'sqlagentcolumn_e' ? true : rows [ 0 ] [ current . column ] ;
1223+ self . results [ current . name ] = current . column === 'sqlagentcolumn_e' ? true : current . datatype === 1 ? parseFloat ( rows [ 0 ] [ current . column ] || 0 ) : rows [ 0 ] [ current . column ] ;
12241224 } else if ( current . first )
12251225 self . results [ current . name ] = rows instanceof Array ? rows [ 0 ] : rows ;
12261226 else
0 commit comments