@@ -98,9 +98,9 @@ yy.Select.prototype.compileGroup = function (query) {
9898 if ( col . aggregatorid === 'SUM' ) {
9999 if ( 'funcid' in col . expression ) {
100100 let colexp1 = colExpIfFunIdExists ( col . expression ) ;
101- return `'${ colas } ':(__alasql_tmp = ${ colexp } , (__alasql_tmp instanceof Date) ? null : ((__alasql_tmp || typeof __alasql_tmp == 'number') ? __alasql_tmp : null )),` ;
101+ return `'${ colas } ':(__alasql_tmp = ${ colexp } , (__alasql_tmp instanceof Date) ? undefined : ((__alasql_tmp || typeof __alasql_tmp == 'number') ? __alasql_tmp : undefined )),` ;
102102 }
103- return `'${ colas } ':(__alasql_tmp = ${ colexp } , (__alasql_tmp instanceof Date) ? null : ((__alasql_tmp || typeof __alasql_tmp == 'number') ? __alasql_tmp : null )),` ;
103+ return `'${ colas } ':(__alasql_tmp = ${ colexp } , (__alasql_tmp instanceof Date) ? undefined : ((__alasql_tmp || typeof __alasql_tmp == 'number') ? __alasql_tmp : undefined )),` ;
104104 } else if ( col . aggregatorid === 'TOTAL' ) {
105105 if ( 'funcid' in col . expression ) {
106106 let colexp1 = colExpIfFunIdExists ( col . expression ) ;
@@ -117,16 +117,16 @@ yy.Select.prototype.compileGroup = function (query) {
117117 if ( 'funcid' in col . expression ) {
118118 let colexp1 = colExpIfFunIdExists ( col . expression ) ;
119119
120- return `'${ colas } ': (__alasql_tmp = ${ colexp } , typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : null ),` ;
120+ return `'${ colas } ': (__alasql_tmp = ${ colexp } , typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : undefined ),` ;
121121 }
122- return `'${ colas } ': (__alasql_tmp = ${ colexp } , typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : null ),` ;
122+ return `'${ colas } ': (__alasql_tmp = ${ colexp } , typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : undefined ),` ;
123123 } else if ( col . aggregatorid === 'MAX' ) {
124124 if ( 'funcid' in col . expression ) {
125125 let colexp1 = colExpIfFunIdExists ( col . expression ) ;
126- return `'${ colas } ': (__alasql_tmp = ${ colexp } , typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : null ),` ;
126+ return `'${ colas } ': (__alasql_tmp = ${ colexp } , typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : undefined ),` ;
127127 }
128128 return `'${ colas } ' : (typeof ${ colexp } == 'number' || typeof ${ colexp } == 'bigint' ? ${ colexp } : typeof ${ colexp } == 'object' ?
129- typeof Number(${ colexp } ) == 'number' ? ${ colexp } : null : null ),` ;
129+ typeof Number(${ colexp } ) == 'number' ? ${ colexp } : undefined : undefined ),` ;
130130 } else if ( col . aggregatorid === 'ARRAY' ) {
131131 return `'${ colas } ':[${ colexp } ],` ;
132132 } else if ( col . aggregatorid === 'COUNT' ) {
@@ -139,7 +139,7 @@ yy.Select.prototype.compileGroup = function (query) {
139139 query . removeKeys . push ( `_SUM_${ colas } ` ) ;
140140 query . removeKeys . push ( `_COUNT_${ colas } ` ) ;
141141
142- return `'${ colas } ':(function() { var t = ${ colexp } ; return (t instanceof Date) ? null : t; })(),'_SUM_${ colas } ':(function() { var t = ${ colexp } ; return (t instanceof Date) ? null : (t || 0); })(),'_COUNT_${ colas } ':(typeof ${ colexp } == "undefined" || ${ colexp } === null) ? 0 : 1,` ;
142+ return `'${ colas } ':(function() { var t = ${ colexp } ; return (t instanceof Date) ? undefined : t; })(),'_SUM_${ colas } ':(function() { var t = ${ colexp } ; return (t instanceof Date) ? undefined : (t || 0); })(),'_COUNT_${ colas } ':(typeof ${ colexp } == "undefined" || ${ colexp } === null) ? 0 : 1,` ;
143143 } else if ( col . aggregatorid === 'AGGR' ) {
144144 aft += `,g['${ colas } ']=${ col . expression . toJS ( 'g' , - 1 ) } ` ;
145145 return '' ;
@@ -183,20 +183,20 @@ yy.Select.prototype.compileGroup = function (query) {
183183 const __colexp1 = ${ colexp1 } ;
184184
185185 if (__g_colas == null && ${ colexp1 } == null) {
186- g['${ colas } '] = null ;
186+ g['${ colas } '] = undefined ;
187187 } else if (typeof __g_colas === 'bigint' || typeof __colexp1 === 'bigint') {
188188 g['${ colas } '] = BigInt(__g_colas) + BigInt(__colexp);
189189 } else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 !== 'object' && __typeof_colexp1 !== 'number') ||
190190 (__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${ colexp1 } == null || (__typeof_colexp1 !== 'number' && __typeof_colexp1 !== 'object'))) {
191- g['${ colas } '] = null ;
191+ g['${ colas } '] = undefined ;
192192 } else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 == 'number') ||
193193 (__g_colas == null && __typeof_colexp1 == 'number')) {
194194 g['${ colas } '] = ${ colexp } ;
195195 } else if (typeof __g_colas == 'number' && ${ colexp1 } == null) {
196196 g['${ colas } '] = __g_colas;
197197 } else if (__g_colas instanceof Date || __colexp1 instanceof Date) {
198- // Date objects cause string concatenation with +=, return null instead
199- g['${ colas } '] = null ;
198+ // Date objects cause string concatenation with +=, return undefined instead
199+ g['${ colas } '] = undefined ;
200200 } else {
201201 g['${ colas } '] += ${ colexp } || 0;
202202 }
@@ -214,26 +214,26 @@ yy.Select.prototype.compileGroup = function (query) {
214214 const __colexp = ${ colexp } ;
215215
216216 if (__g_colas == null && ${ colexp } == null) {
217- g['${ colas } '] = null ;
217+ g['${ colas } '] = undefined ;
218218 } else if (typeof __g_colas === 'bigint' || typeof __colexp === 'bigint') {
219219 g['${ colas } '] = BigInt(__g_colas) + BigInt(__colexp);
220220 } else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp !== 'object' && __typeof_colexp !== 'number') ||
221221 (__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${ colexp } == null || (__typeof_colexp !== 'number' && __typeof_colexp !== 'object'))) {
222- g['${ colas } '] = null;
223- } else if (typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp == 'number') {
224- g['${ colas } '] = ${ colexp } ;
225- } else if (typeof __g_colas == 'number' && ${ colexp } == null) {
226- g['${ colas } '] = __g_colas;
227- } else if (__g_colas == null && __typeof_colexp == 'number') {
228- g['${ colas } '] = ${ colexp } ;
229- } else if (__g_colas instanceof Date || __colexp instanceof Date) {
230- // Date objects cause string concatenation with +=, return null instead
231- g['${ colas } '] = null;
232- } else {
233- g['${ colas } '] += ${ colexp } || 0;
234- }
222+ g['${ colas } '] = undefined;
223+ } else if (typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp == 'number') {
224+ g['${ colas } '] = ${ colexp } ;
225+ } else if (typeof __g_colas == 'number' && ${ colexp } == null) {
226+ g['${ colas } '] = __g_colas;
227+ } else if (__g_colas == null && __typeof_colexp == 'number') {
228+ g['${ colas } '] = ${ colexp } ;
229+ } else if (__g_colas instanceof Date || __colexp instanceof Date) {
230+ // Date objects cause string concatenation with +=, return undefined instead
231+ g['${ colas } '] = undefined;
232+ } else {
233+ g['${ colas } '] += ${ colexp } || 0;
235234 }
236- ` +
235+ }
236+ ` +
237237 post
238238 ) ;
239239 } else if ( col . aggregatorid === 'TOTAL' ) {
@@ -398,9 +398,9 @@ yy.Select.prototype.compileGroup = function (query) {
398398 y= (${ colexp } );
399399 g['_COUNT_${ colas } '] += (typeof y == "undefined" || y === null) ? 0 : 1;
400400 if (y instanceof Date || (g['_SUM_${ colas } '] && g['_SUM_${ colas } '] instanceof Date)) {
401- // AVG on Date objects doesn't make semantic sense - return null
402- g['_SUM_${ colas } '] = null ;
403- g['${ colas } '] = null ;
401+ // AVG on Date objects doesn't make semantic sense - return undefined
402+ g['_SUM_${ colas } '] = undefined ;
403+ g['${ colas } '] = undefined ;
404404 } else if (typeof g['_SUM_${ colas } '] === 'bigint' || typeof y === 'bigint') {
405405 g['_SUM_${ colas } '] = BigInt(g['_SUM_${ colas } ']);
406406 g['_SUM_${ colas } '] += BigInt(y || 0);
0 commit comments