alasql 4.1.7 → 4.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.6 build: develop-a1db25b2 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.8 build: develop-274f71f6 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.6
4
+ @version 4.1.8
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -1,2 +1,2 @@
1
- //! AlaSQL v4.1.6 build: develop-a1db25b2 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.8 build: develop-274f71f6 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  !function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function i(r,e,o){"function"==typeof(e=e||[])&&(scope=o,o=e,e=[]),"object"!=typeof e&&(e=[e]);var t=i.lastid++;i.buffer[t]=o,i.webworker.postMessage({id:t,sql:r,params:e})}var a;if(i.options={},i.options.progress=function(){},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)},i.promise=function(){throw new Error("Please include a Promise/A+ library")},"undefined"!=typeof Promise&&(a=function(r,e,n,s){return new Promise(function(o,t){i(r,e,function(r,e){e?t(e):(n&&s&&!1!==i.options.progress&&i.options.progress(n,s),o(r))})})},i.promise=function(r,e){if("undefined"==typeof Promise)throw new Error("Please include a Promise/A+ library");if("string"==typeof r)return a(r,e);if(!isArray(r)||r.length<1||void 0!==e)throw new Error("Error in .promise parameters");var o=r;if(!(o.length<1)){for(var t,n,s=[],i=0;i<o.length;i++){if("string"==typeof(n=o[i])&&(n=[n]),!isArray(n)||n.length<1||2<n.length)throw new Error("Error in .promise parameter");t=n[0],n=n[1]||void 0,s.push(a(t,n,i,o.length))}return Promise.all(s)}}),i=i||!1)return i.worker=function(){throw new Error("Can find webworker in this enviroment")},"undefined"!=typeof Worker&&(i.worker=function(r,e,o){if(void 0===(r=!0===r?void 0:r))for(var t=document.getElementsByTagName("script"),n=0;n<t.length;n++){if("alasql-worker.js"===t[n].src.substr(-16).toLowerCase()){r=t[n].src.substr(0,t[n].src.length-16)+"alasql.js";break}if("alasql-worker.min.js"===t[n].src.substr(-20).toLowerCase()){r=t[n].src.substr(0,t[n].src.length-20)+"alasql.min.js";break}if("alasql.js"===t[n].src.substr(-9).toLowerCase()){r=t[n].src;break}if("alasql.min.js"===t[n].src.substr(-13).toLowerCase()){r=t[n].src.substr(0,t[n].src.length-13)+"alasql.min.js";break}}if(void 0===r)throw new Error("Path to alasql.js is not specified");var s;!1!==r?(s=(s="importScripts('")+r+"');self.onmessage = function(event) {alasql(event.data.sql,event.data.params, function(data){postMessage({id:event.data.id, data:data});});}",s=new Blob([s],{type:"text/plain"}),i.webworker=new Worker(URL.createObjectURL(s)),i.webworker.onmessage=function(r){var e=r.data.id;i.buffer[e](r.data.data),delete i.buffer[e]},i.webworker.onerror=function(r){throw r},1<arguments.length&&i("REQUIRE "+e.map(function(r){return'"'+r+'"'}).join(","),[],o)):!1===r&&delete i.webworker}),i.lastid=0,i.buffer={},i.worker(),i;throw new Error("alasql was not found")});
package/dist/alasql.fs.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.6 build: develop-a1db25b2 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.8 build: develop-274f71f6 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.6
4
+ @version 4.1.8
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -142,8 +142,8 @@ var alasql = function(sql, params, cb, scope) {
142
142
  Current version of alasql
143
143
  @constant {string}
144
144
  */
145
- alasql.version = '4.1.6';
146
- alasql.build = 'develop-a1db25b2';
145
+ alasql.version = '4.1.8';
146
+ alasql.build = 'develop-274f71f6';
147
147
 
148
148
  /**
149
149
  Debug flag
@@ -4235,7 +4235,7 @@ var like = (utils.like = function (pattern, value, escape) {
4235
4235
  } else if (c === '[' || c === ']') {
4236
4236
  s += c;
4237
4237
  } else if (c === '%') {
4238
- s += '.*';
4238
+ s += '[\\s\\S]*';
4239
4239
  } else if (c === '_') {
4240
4240
  s += '.';
4241
4241
  } else if ('/.*+?|(){}'.indexOf(c) > -1) {
@@ -4249,7 +4249,7 @@ var like = (utils.like = function (pattern, value, escape) {
4249
4249
  s += '$';
4250
4250
  // if(value == undefined) return false;
4251
4251
 
4252
- return ('' + (value || '')).toUpperCase().search(RegExp(s.toUpperCase())) > -1;
4252
+ return ('' + (value ?? '')).search(RegExp(s, 'i')) > -1;
4253
4253
  });
4254
4254
 
4255
4255
  utils.glob = function (value, pattern) {
@@ -8244,7 +8244,12 @@ yy.Select.prototype.compileJoins = function (query) {
8244
8244
  // if(jn instanceof yy.Apply) {
8245
8245
  source.datafn = function (query, params, cb, idx, alasql) {
8246
8246
  // return cb(null,idx,alasql);
8247
- return source.subquery(query.params, null, cb, idx).data;
8247
+ source.data = source.subquery(query.params, null, cb, idx).data;
8248
+ // var res = alasql.prepareFromData(params[idx]);
8249
+ var res = source.data;
8250
+ // Propogate subquery result
8251
+ if (cb) res = cb(res, idx, query);
8252
+ return res;
8248
8253
  };
8249
8254
  // } else {
8250
8255
  // source.datafn = function(query, params, cb, idx, alasql) {
@@ -8740,8 +8745,8 @@ yy.Select.prototype.compileGroup = function (query) {
8740
8745
  if ('funcid' in col.expression) {
8741
8746
  let colexp1 = colExpIfFunIdExists(col.expression);
8742
8747
 
8743
- return(`'${colas}': (typeof ${colexp1} == 'number' ? ${colexp} : typeof ${colexp1} == 'object' ?
8744
- typeof Number(${colexp1}) == 'number' && ${colexp1}!== null? ${colexp} : null : null),`);
8748
+ return `'${colas}': (typeof ${colexp1} == 'number' ? ${colexp} : typeof ${colexp1} == 'object' ?
8749
+ typeof Number(${colexp1}) == 'number' && ${colexp1}!== null? ${colexp} : null : null),`;
8745
8750
  }
8746
8751
  return `'${colas}': (typeof ${colexp} == 'number' ? ${colexp} : typeof ${colexp} == 'object' ?
8747
8752
  typeof Number(${colexp}) == 'number' && ${colexp}!== null? ${colexp} : null : null),`;
@@ -8915,7 +8920,7 @@ yy.Select.prototype.compileGroup = function (query) {
8915
8920
  if ('funcid' in col.expression) {
8916
8921
  let colexp1 = colExpIfFunIdExists(col.expression);
8917
8922
 
8918
- return(
8923
+ return (
8919
8924
  pre +
8920
8925
  `if((g['${colas}'] == null && ${colexp1}!== null) ? y = ${colexp} : (g['${colas}']!== null &&
8921
8926
  ${colexp1} == null) ? y = g['${colas}']:((y=${colexp}) < g['${colas}'])){ if(typeof y == 'number')
@@ -8940,7 +8945,7 @@ yy.Select.prototype.compileGroup = function (query) {
8940
8945
  if ('funcid' in col.expression) {
8941
8946
  let colexp1 = colExpIfFunIdExists(col.expression);
8942
8947
 
8943
- return(
8948
+ return (
8944
8949
  pre +
8945
8950
  `if((g['${colas}'] == null && ${colexp1}!== null) ? y = ${colexp} : (g['${colas}']!== null &&
8946
8951
  ${colexp1} == null) ? y = g['${colas}']:((y=${colexp}) > g['${colas}'])){ if(typeof y == 'number')
@@ -12137,18 +12142,18 @@ function structuredDate(unFormattedDate) {
12137
12142
  var formattedSeconds = ('0' + unFormattedDate.getSeconds()).substr(-2);
12138
12143
  var formattedMilliseconds = ('00' + unFormattedDate.getMilliseconds()).substr(-3);
12139
12144
  return {
12140
- month: month,
12141
- year: year,
12142
- fullYear: fullYear,
12143
- date: date,
12144
- day: day,
12145
- formattedDate: formattedDate,
12146
- formattedMonth: formattedMonth,
12147
- formattedYear: formattedYear,
12148
- formattedHour: formattedHour,
12149
- formattedMinutes: formattedMinutes,
12150
- formattedSeconds: formattedSeconds,
12151
- formattedMilliseconds: formattedMilliseconds,
12145
+ month,
12146
+ year,
12147
+ fullYear,
12148
+ date,
12149
+ day,
12150
+ formattedDate,
12151
+ formattedMonth,
12152
+ formattedYear,
12153
+ formattedHour,
12154
+ formattedMinutes,
12155
+ formattedSeconds,
12156
+ formattedMilliseconds,
12152
12157
  };
12153
12158
  }
12154
12159
 
@@ -12157,7 +12162,7 @@ function structuredDate(unFormattedDate) {
12157
12162
  */
12158
12163
  alasql.stdfn.CONVERT = function (value, args) {
12159
12164
  var val = value;
12160
- var udbtypeid = args.dbtypeid.toUpperCase();
12165
+ var udbtypeid = args.dbtypeid?.toUpperCase();
12161
12166
 
12162
12167
  var t;
12163
12168
  var s;
@@ -12992,7 +12997,7 @@ stdfn.ASCII = function (a) {
12992
12997
  return a.charCodeAt(0);
12993
12998
  };
12994
12999
 
12995
- /**
13000
+ /**
12996
13001
  Return first non-null argument
12997
13002
  See https://msdn.microsoft.com/en-us/library/ms190349.aspx
12998
13003
  */
@@ -13093,7 +13098,7 @@ var PERIODS = {
13093
13098
 
13094
13099
  alasql.stdfn.DATEDIFF = function (period, d1, d2) {
13095
13100
  var interval = newDate(d2).getTime() - newDate(d1).getTime();
13096
- return interval / PERIODS[period.toLowerCase()];
13101
+ return (interval / PERIODS[period.toLowerCase()]) | 0;
13097
13102
  };
13098
13103
 
13099
13104
  alasql.stdfn.DATEADD = function (period, interval, d) {
@@ -13191,7 +13196,7 @@ yy.DropTable.prototype.execute = function (databaseid, params, cb) {
13191
13196
  if (!db.tables[tableid]) {
13192
13197
  if (!alasql.options.dropifnotexists) {
13193
13198
  throw new Error(
13194
- `Can not drop table ${JSON.strnigify(
13199
+ `Can not drop table ${JSON.stringify(
13195
13200
  table.tableid
13196
13201
  )} because it does not exist in the database.`
13197
13202
  );
package/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.6 build: develop-a1db25b2 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.8 build: develop-274f71f6 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.6
4
+ @version 4.1.8
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -142,8 +142,8 @@ var alasql = function(sql, params, cb, scope) {
142
142
  Current version of alasql
143
143
  @constant {string}
144
144
  */
145
- alasql.version = '4.1.6';
146
- alasql.build = 'develop-a1db25b2';
145
+ alasql.version = '4.1.8';
146
+ alasql.build = 'develop-274f71f6';
147
147
 
148
148
  /**
149
149
  Debug flag
@@ -4235,7 +4235,7 @@ var like = (utils.like = function (pattern, value, escape) {
4235
4235
  } else if (c === '[' || c === ']') {
4236
4236
  s += c;
4237
4237
  } else if (c === '%') {
4238
- s += '.*';
4238
+ s += '[\\s\\S]*';
4239
4239
  } else if (c === '_') {
4240
4240
  s += '.';
4241
4241
  } else if ('/.*+?|(){}'.indexOf(c) > -1) {
@@ -4249,7 +4249,7 @@ var like = (utils.like = function (pattern, value, escape) {
4249
4249
  s += '$';
4250
4250
  // if(value == undefined) return false;
4251
4251
 
4252
- return ('' + (value || '')).toUpperCase().search(RegExp(s.toUpperCase())) > -1;
4252
+ return ('' + (value ?? '')).search(RegExp(s, 'i')) > -1;
4253
4253
  });
4254
4254
 
4255
4255
  utils.glob = function (value, pattern) {
@@ -8244,7 +8244,12 @@ yy.Select.prototype.compileJoins = function (query) {
8244
8244
  // if(jn instanceof yy.Apply) {
8245
8245
  source.datafn = function (query, params, cb, idx, alasql) {
8246
8246
  // return cb(null,idx,alasql);
8247
- return source.subquery(query.params, null, cb, idx).data;
8247
+ source.data = source.subquery(query.params, null, cb, idx).data;
8248
+ // var res = alasql.prepareFromData(params[idx]);
8249
+ var res = source.data;
8250
+ // Propogate subquery result
8251
+ if (cb) res = cb(res, idx, query);
8252
+ return res;
8248
8253
  };
8249
8254
  // } else {
8250
8255
  // source.datafn = function(query, params, cb, idx, alasql) {
@@ -8740,8 +8745,8 @@ yy.Select.prototype.compileGroup = function (query) {
8740
8745
  if ('funcid' in col.expression) {
8741
8746
  let colexp1 = colExpIfFunIdExists(col.expression);
8742
8747
 
8743
- return(`'${colas}': (typeof ${colexp1} == 'number' ? ${colexp} : typeof ${colexp1} == 'object' ?
8744
- typeof Number(${colexp1}) == 'number' && ${colexp1}!== null? ${colexp} : null : null),`);
8748
+ return `'${colas}': (typeof ${colexp1} == 'number' ? ${colexp} : typeof ${colexp1} == 'object' ?
8749
+ typeof Number(${colexp1}) == 'number' && ${colexp1}!== null? ${colexp} : null : null),`;
8745
8750
  }
8746
8751
  return `'${colas}': (typeof ${colexp} == 'number' ? ${colexp} : typeof ${colexp} == 'object' ?
8747
8752
  typeof Number(${colexp}) == 'number' && ${colexp}!== null? ${colexp} : null : null),`;
@@ -8915,7 +8920,7 @@ yy.Select.prototype.compileGroup = function (query) {
8915
8920
  if ('funcid' in col.expression) {
8916
8921
  let colexp1 = colExpIfFunIdExists(col.expression);
8917
8922
 
8918
- return(
8923
+ return (
8919
8924
  pre +
8920
8925
  `if((g['${colas}'] == null && ${colexp1}!== null) ? y = ${colexp} : (g['${colas}']!== null &&
8921
8926
  ${colexp1} == null) ? y = g['${colas}']:((y=${colexp}) < g['${colas}'])){ if(typeof y == 'number')
@@ -8940,7 +8945,7 @@ yy.Select.prototype.compileGroup = function (query) {
8940
8945
  if ('funcid' in col.expression) {
8941
8946
  let colexp1 = colExpIfFunIdExists(col.expression);
8942
8947
 
8943
- return(
8948
+ return (
8944
8949
  pre +
8945
8950
  `if((g['${colas}'] == null && ${colexp1}!== null) ? y = ${colexp} : (g['${colas}']!== null &&
8946
8951
  ${colexp1} == null) ? y = g['${colas}']:((y=${colexp}) > g['${colas}'])){ if(typeof y == 'number')
@@ -12137,18 +12142,18 @@ function structuredDate(unFormattedDate) {
12137
12142
  var formattedSeconds = ('0' + unFormattedDate.getSeconds()).substr(-2);
12138
12143
  var formattedMilliseconds = ('00' + unFormattedDate.getMilliseconds()).substr(-3);
12139
12144
  return {
12140
- month: month,
12141
- year: year,
12142
- fullYear: fullYear,
12143
- date: date,
12144
- day: day,
12145
- formattedDate: formattedDate,
12146
- formattedMonth: formattedMonth,
12147
- formattedYear: formattedYear,
12148
- formattedHour: formattedHour,
12149
- formattedMinutes: formattedMinutes,
12150
- formattedSeconds: formattedSeconds,
12151
- formattedMilliseconds: formattedMilliseconds,
12145
+ month,
12146
+ year,
12147
+ fullYear,
12148
+ date,
12149
+ day,
12150
+ formattedDate,
12151
+ formattedMonth,
12152
+ formattedYear,
12153
+ formattedHour,
12154
+ formattedMinutes,
12155
+ formattedSeconds,
12156
+ formattedMilliseconds,
12152
12157
  };
12153
12158
  }
12154
12159
 
@@ -12157,7 +12162,7 @@ function structuredDate(unFormattedDate) {
12157
12162
  */
12158
12163
  alasql.stdfn.CONVERT = function (value, args) {
12159
12164
  var val = value;
12160
- var udbtypeid = args.dbtypeid.toUpperCase();
12165
+ var udbtypeid = args.dbtypeid?.toUpperCase();
12161
12166
 
12162
12167
  var t;
12163
12168
  var s;
@@ -12992,7 +12997,7 @@ stdfn.ASCII = function (a) {
12992
12997
  return a.charCodeAt(0);
12993
12998
  };
12994
12999
 
12995
- /**
13000
+ /**
12996
13001
  Return first non-null argument
12997
13002
  See https://msdn.microsoft.com/en-us/library/ms190349.aspx
12998
13003
  */
@@ -13093,7 +13098,7 @@ var PERIODS = {
13093
13098
 
13094
13099
  alasql.stdfn.DATEDIFF = function (period, d1, d2) {
13095
13100
  var interval = newDate(d2).getTime() - newDate(d1).getTime();
13096
- return interval / PERIODS[period.toLowerCase()];
13101
+ return (interval / PERIODS[period.toLowerCase()]) | 0;
13097
13102
  };
13098
13103
 
13099
13104
  alasql.stdfn.DATEADD = function (period, interval, d) {
@@ -13191,7 +13196,7 @@ yy.DropTable.prototype.execute = function (databaseid, params, cb) {
13191
13196
  if (!db.tables[tableid]) {
13192
13197
  if (!alasql.options.dropifnotexists) {
13193
13198
  throw new Error(
13194
- `Can not drop table ${JSON.strnigify(
13199
+ `Can not drop table ${JSON.stringify(
13195
13200
  table.tableid
13196
13201
  )} because it does not exist in the database.`
13197
13202
  );