alasql 4.1.3 → 4.1.5
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.
- package/README.md +3 -3
- package/dist/alasql-worker.js +2 -2
- package/dist/alasql-worker.min.js +1 -1
- package/dist/alasql.d.ts +14 -0
- package/dist/alasql.fs.js +75 -57
- package/dist/alasql.js +75 -57
- package/dist/alasql.min.js +5 -5
- package/package.json +20 -23
- package/types/alasql.d.ts +14 -0
- package/test239.json +0 -3
package/README.md
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
[](http://open-oss.com)
|
|
8
8
|
[](https://www.npmjs.com/package/alasql)
|
|
9
9
|
[](https://github.com/alasql/alasql)
|
|
10
|
-
[](http://isitmaintained.com/project/AlaSQL/alasql "Average time to resolve an issue")
|
|
11
11
|
[](https://rawgit.com/alasql/alasql/develop/test/coverage/lcov-report/dist/alasql.fs.js.html)
|
|
12
|
-
[](https://securityscorecards.dev/viewer/?uri=github.com/AlaSQL/alasql)
|
|
13
|
+
[](https://bestpractices.coreinfrastructure.org/projects/328)
|
|
13
14
|
[](https://www.jsdelivr.com/package/npm/alasql)
|
|
14
|
-
[](https://github.com/prettier/prettier)
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
package/dist/alasql-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v4.1.
|
|
1
|
+
//! AlaSQL v4.1.4 build: develop-b2979cbc | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 4.1.
|
|
4
|
+
@version 4.1.4
|
|
5
5
|
|
|
6
6
|
AlaSQL - JavaScript SQL database
|
|
7
7
|
© 2014-2023 Andrey Gershun & Mathias Wulff
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
//! AlaSQL v4.1.
|
|
1
|
+
//! AlaSQL v4.1.4 build: develop-b2979cbc | © 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.d.ts
CHANGED
|
@@ -60,17 +60,28 @@ declare module 'alasql' {
|
|
|
60
60
|
interface userDefinedFunction {
|
|
61
61
|
(...x: any[]): any;
|
|
62
62
|
}
|
|
63
|
+
|
|
63
64
|
interface userDefinedFunctionLookUp {
|
|
64
65
|
[x: string]: userDefinedFunction;
|
|
65
66
|
}
|
|
67
|
+
|
|
66
68
|
// see https://github.com/alasql/alasql/wiki/User%20Defined%20Functions
|
|
67
69
|
interface userAggregator {
|
|
68
70
|
(value: any, accumulator: any, stage: number): any;
|
|
69
71
|
}
|
|
72
|
+
|
|
70
73
|
interface userAggregatorLookUp {
|
|
71
74
|
[x: string]: userAggregator;
|
|
72
75
|
}
|
|
73
76
|
|
|
77
|
+
interface userFromFunction {
|
|
78
|
+
(dataReference: any, options: any, callback: any, index: any, query: any): any;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface userFromFunctionLookUp {
|
|
82
|
+
[x: string]: userFromFunction;
|
|
83
|
+
}
|
|
84
|
+
|
|
74
85
|
interface AlaSQL {
|
|
75
86
|
options: AlaSQLOptions;
|
|
76
87
|
error: Error;
|
|
@@ -78,11 +89,14 @@ declare module 'alasql' {
|
|
|
78
89
|
parse(sql: any): AlaSQLAST;
|
|
79
90
|
promise(sql: any, params?: any): Thenable<any>;
|
|
80
91
|
fn: userDefinedFunctionLookUp;
|
|
92
|
+
from: userFromFunctionLookUp;
|
|
81
93
|
aggr: userAggregatorLookUp;
|
|
82
94
|
autoval(tablename: string, colname: string, getNext?: boolean): number;
|
|
83
95
|
yy: {};
|
|
84
96
|
setXLSX(xlsxlib: typeof xlsx): void;
|
|
85
97
|
}
|
|
98
|
+
|
|
86
99
|
const alasql: AlaSQL;
|
|
100
|
+
|
|
87
101
|
export = alasql;
|
|
88
102
|
}
|
package/dist/alasql.fs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v4.1.
|
|
1
|
+
//! AlaSQL v4.1.4 build: develop-b2979cbc | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 4.1.
|
|
4
|
+
@version 4.1.4
|
|
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.
|
|
146
|
-
alasql.build = 'develop-
|
|
145
|
+
alasql.version = '4.1.4';
|
|
146
|
+
alasql.build = 'develop-b2979cbc';
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
149
|
Debug flag
|
|
@@ -3490,7 +3490,7 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3490
3490
|
});
|
|
3491
3491
|
} else {
|
|
3492
3492
|
if (/^[a-z]+:\/\//i.test(path)) {
|
|
3493
|
-
fetchData(path,
|
|
3493
|
+
fetchData(path, x => success(cutbom(x)), error, asy);
|
|
3494
3494
|
} else {
|
|
3495
3495
|
//If async callthen call async
|
|
3496
3496
|
if (asy) {
|
|
@@ -3553,7 +3553,7 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
|
|
|
3553
3553
|
Simply read file from HTTP request, like:
|
|
3554
3554
|
SELECT * FROM TXT('http://alasql.org/README.md');
|
|
3555
3555
|
*/
|
|
3556
|
-
fetchData(path,
|
|
3556
|
+
fetchData(path, x => success(cutbom(x)), error, asy);
|
|
3557
3557
|
}
|
|
3558
3558
|
} else if (path instanceof Event) {
|
|
3559
3559
|
/*
|
|
@@ -3594,13 +3594,13 @@ async function fetchData(path, success, error, async) {
|
|
|
3594
3594
|
|
|
3595
3595
|
function getData(path, success, error) {
|
|
3596
3596
|
return _fetch(path)
|
|
3597
|
-
.then(
|
|
3598
|
-
.then(
|
|
3597
|
+
.then(response => response.arrayBuffer())
|
|
3598
|
+
.then(buf => {
|
|
3599
3599
|
var a = new Uint8Array(buf);
|
|
3600
|
-
var b = [...a].map(
|
|
3600
|
+
var b = [...a].map(e => String.fromCharCode(e)).join('');
|
|
3601
3601
|
success(b);
|
|
3602
3602
|
})
|
|
3603
|
-
.catch(
|
|
3603
|
+
.catch(e => {
|
|
3604
3604
|
if (error) return error(e);
|
|
3605
3605
|
console.error(e);
|
|
3606
3606
|
throw e;
|
|
@@ -3622,7 +3622,7 @@ var loadBinaryFile = (utils.loadBinaryFile = function (
|
|
|
3622
3622
|
path,
|
|
3623
3623
|
runAsync,
|
|
3624
3624
|
success,
|
|
3625
|
-
error =
|
|
3625
|
+
error = x => {
|
|
3626
3626
|
throw x;
|
|
3627
3627
|
}
|
|
3628
3628
|
) {
|
|
@@ -4866,9 +4866,9 @@ var promiseExec = function (sql, params, counterStep, counterTotal) {
|
|
|
4866
4866
|
|
|
4867
4867
|
const sequentialPromiseResolver = (promiseData, Promise) => {
|
|
4868
4868
|
var startingPoint = Promise.resolve([]);
|
|
4869
|
-
promiseData.forEach(
|
|
4870
|
-
startingPoint = startingPoint.then(
|
|
4871
|
-
promiseExec(p.sql, p.params, p.i, p.length).then(
|
|
4869
|
+
promiseData.forEach(p => {
|
|
4870
|
+
startingPoint = startingPoint.then(previousResult =>
|
|
4871
|
+
promiseExec(p.sql, p.params, p.i, p.length).then(result => [...previousResult, result])
|
|
4872
4872
|
);
|
|
4873
4873
|
});
|
|
4874
4874
|
|
|
@@ -5272,16 +5272,16 @@ yy.Statements = class Statements {
|
|
|
5272
5272
|
}
|
|
5273
5273
|
|
|
5274
5274
|
toString() {
|
|
5275
|
-
return this.statements.map(
|
|
5275
|
+
return this.statements.map(st => st.toString()).join('; ');
|
|
5276
5276
|
}
|
|
5277
5277
|
|
|
5278
5278
|
// Compile array of statements into single statement
|
|
5279
5279
|
compile(db) {
|
|
5280
|
-
const statements = this.statements.map(
|
|
5280
|
+
const statements = this.statements.map(st => st.compile(db));
|
|
5281
5281
|
return statements.length === 1
|
|
5282
5282
|
? statements[0]
|
|
5283
5283
|
: (params, cb) => {
|
|
5284
|
-
const res = statements.map(
|
|
5284
|
+
const res = statements.map(st => st(params));
|
|
5285
5285
|
if (cb) cb(res);
|
|
5286
5286
|
return res;
|
|
5287
5287
|
};
|
|
@@ -5973,7 +5973,7 @@ alasql.srch = {
|
|
|
5973
5973
|
PROP(val, args, stope) {
|
|
5974
5974
|
|
|
5975
5975
|
if (stope.mode === 'XML') {
|
|
5976
|
-
const values = val.children.filter(
|
|
5976
|
+
const values = val.children.filter(v => v.name.toUpperCase() === args[0].toUpperCase());
|
|
5977
5977
|
|
|
5978
5978
|
return {
|
|
5979
5979
|
status: values.length ? 1 : -1,
|
|
@@ -6311,7 +6311,7 @@ alasql.srch = {
|
|
|
6311
6311
|
|
|
6312
6312
|
ROW(val, args, stope, params) {
|
|
6313
6313
|
var s = 'var y;return [';
|
|
6314
|
-
s += args.map(
|
|
6314
|
+
s += args.map(arg => arg.toJS('x', '')).join(',');
|
|
6315
6315
|
s += ']';
|
|
6316
6316
|
var setfn = new Function('x,params,alasql', s);
|
|
6317
6317
|
var rv = setfn(val, params, alasql);
|
|
@@ -6481,7 +6481,7 @@ function queryfn(query, oldscope, cb, A, B) {
|
|
|
6481
6481
|
|
|
6482
6482
|
// First - refresh data sources
|
|
6483
6483
|
|
|
6484
|
-
|
|
6484
|
+
let result;
|
|
6485
6485
|
query.sources.forEach(function (source, idx) {
|
|
6486
6486
|
// source.data = query.database.tables[source.tableid].data;
|
|
6487
6487
|
|
|
@@ -6502,7 +6502,14 @@ function queryfn(query, oldscope, cb, A, B) {
|
|
|
6502
6502
|
//
|
|
6503
6503
|
source.queriesdata = query.queriesdata;
|
|
6504
6504
|
});
|
|
6505
|
-
if (query.sources.length == 0 || 0 === slen)
|
|
6505
|
+
if (query.sources.length == 0 || 0 === slen) {
|
|
6506
|
+
try {
|
|
6507
|
+
result = queryfn3(query);
|
|
6508
|
+
} catch (e) {
|
|
6509
|
+
if (cb) return cb(null, e);
|
|
6510
|
+
else throw e;
|
|
6511
|
+
}
|
|
6512
|
+
}
|
|
6506
6513
|
|
|
6507
6514
|
return result;
|
|
6508
6515
|
}
|
|
@@ -7551,8 +7558,8 @@ yy.Select = class Select {
|
|
|
7551
7558
|
.intoTable(
|
|
7552
7559
|
${JSON.stringify(this.into.databaseid || databaseid)},
|
|
7553
7560
|
${JSON.stringify(this.into.tableid)},
|
|
7554
|
-
this.data,
|
|
7555
|
-
columns,
|
|
7561
|
+
this.data,
|
|
7562
|
+
columns,
|
|
7556
7563
|
cb
|
|
7557
7564
|
);`;
|
|
7558
7565
|
} else {
|
|
@@ -7619,7 +7626,7 @@ yy.Select = class Select {
|
|
|
7619
7626
|
// the (data, err) standard is maintained here.
|
|
7620
7627
|
var res1 = queryfn(query, oldscope, function (res, err) {
|
|
7621
7628
|
if (err) {
|
|
7622
|
-
return cb(
|
|
7629
|
+
return cb(null, err);
|
|
7623
7630
|
}
|
|
7624
7631
|
if (query.rownums.length > 0) {
|
|
7625
7632
|
for (var i = 0, ilen = res.length; i < ilen; i++) {
|
|
@@ -8625,9 +8632,6 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8625
8632
|
query.allgroups = allgroups;
|
|
8626
8633
|
|
|
8627
8634
|
query.ingroup = [];
|
|
8628
|
-
|
|
8629
|
-
// Create negative array
|
|
8630
|
-
|
|
8631
8635
|
var s = '';
|
|
8632
8636
|
// s+= query.selectfns;
|
|
8633
8637
|
allgroup.forEach(function (agroup) {
|
|
@@ -8700,7 +8704,7 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8700
8704
|
// if(col instanceof yy.Column) colas = col.columnid;
|
|
8701
8705
|
// else colas = col.toString();
|
|
8702
8706
|
// };
|
|
8703
|
-
let colExpIfFunIdExists =
|
|
8707
|
+
let colExpIfFunIdExists = expression => {
|
|
8704
8708
|
let colexpression = expression.args[0];
|
|
8705
8709
|
return colexpression.toJS('p', tableid, defcols);
|
|
8706
8710
|
};
|
|
@@ -8811,21 +8815,13 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8811
8815
|
|
|
8812
8816
|
s += '}' + aft + ',g));' + aft2 + '} else {';
|
|
8813
8817
|
|
|
8814
|
-
/*
|
|
8815
|
-
// var neggroup = arrayDiff(allgroups,agroup);
|
|
8816
|
-
|
|
8817
|
-
// s += neggroup.map(function(columnid){
|
|
8818
|
-
// return "g['"+columnid+"']=null;";
|
|
8819
|
-
// }).join('');
|
|
8820
|
-
*/
|
|
8821
|
-
|
|
8822
8818
|
// s += self.columns.map(function(col){
|
|
8823
8819
|
s += query.selectGroup
|
|
8824
8820
|
.map(function (col) {
|
|
8825
8821
|
var colas = col.nick;
|
|
8826
8822
|
|
|
8827
8823
|
var colexp = col.expression.toJS('p', tableid, defcols);
|
|
8828
|
-
let colExpIfFunIdExists =
|
|
8824
|
+
let colExpIfFunIdExists = expression => {
|
|
8829
8825
|
let colexpression = expression.args[0];
|
|
8830
8826
|
return colexpression.toJS('p', tableid, defcols);
|
|
8831
8827
|
};
|
|
@@ -11665,7 +11661,7 @@ stdlib.UPPER = stdlib.UCASE = function (s) {
|
|
|
11665
11661
|
// Concatination of strings
|
|
11666
11662
|
stdfn.CONCAT_WS = function () {
|
|
11667
11663
|
var args = Array.prototype.slice.call(arguments);
|
|
11668
|
-
args = args.filter(
|
|
11664
|
+
args = args.filter(x => !(x === null || typeof x === 'undefined'));
|
|
11669
11665
|
return args.slice(1, args.length).join(args[0] || '');
|
|
11670
11666
|
};
|
|
11671
11667
|
|
|
@@ -12601,7 +12597,11 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) {
|
|
|
12601
12597
|
};
|
|
12602
12598
|
}
|
|
12603
12599
|
if (checkfn) {
|
|
12604
|
-
table.checks.push({
|
|
12600
|
+
table.checks.push({
|
|
12601
|
+
fn: checkfn,
|
|
12602
|
+
id: con.constraintid,
|
|
12603
|
+
fk: con.type === 'FOREIGN KEY',
|
|
12604
|
+
});
|
|
12605
12605
|
}
|
|
12606
12606
|
});
|
|
12607
12607
|
|
|
@@ -13991,7 +13991,9 @@ yy.WithSelect.prototype.execute = function (databaseid, params, cb) {
|
|
|
13991
13991
|
var savedTables = [];
|
|
13992
13992
|
self.withs.forEach(function (w) {
|
|
13993
13993
|
savedTables.push(alasql.databases[databaseid].tables[w.name]);
|
|
13994
|
-
var tb = (alasql.databases[databaseid].tables[w.name] = new Table({
|
|
13994
|
+
var tb = (alasql.databases[databaseid].tables[w.name] = new Table({
|
|
13995
|
+
tableid: w.name,
|
|
13996
|
+
}));
|
|
13995
13997
|
tb.data = w.select.execute(databaseid, params);
|
|
13996
13998
|
});
|
|
13997
13999
|
|
|
@@ -15240,7 +15242,11 @@ yy.ShowColumns.prototype.execute = function (databaseid, params, cb) {
|
|
|
15240
15242
|
|
|
15241
15243
|
if (table && table.columns) {
|
|
15242
15244
|
var res = table.columns.map(function (col) {
|
|
15243
|
-
return {
|
|
15245
|
+
return {
|
|
15246
|
+
columnid: col.columnid,
|
|
15247
|
+
dbtypeid: col.dbtypeid,
|
|
15248
|
+
dbsize: col.dbsize,
|
|
15249
|
+
};
|
|
15244
15250
|
});
|
|
15245
15251
|
if (cb) cb(res);
|
|
15246
15252
|
return res;
|
|
@@ -16898,7 +16904,9 @@ alasql.into.XLSX = function (filename, opts, data, columns, cb) {
|
|
|
16898
16904
|
|
|
16899
16905
|
if (opt.headers) {
|
|
16900
16906
|
columns.forEach(function (col, idx) {
|
|
16901
|
-
cells[alasql.utils.xlsnc(col0 + idx) + '' + i] = {
|
|
16907
|
+
cells[alasql.utils.xlsnc(col0 + idx) + '' + i] = {
|
|
16908
|
+
v: col.columnid.trim(),
|
|
16909
|
+
};
|
|
16902
16910
|
});
|
|
16903
16911
|
i++;
|
|
16904
16912
|
}
|
|
@@ -17331,9 +17339,17 @@ function XLSXLSX(X, filename, opts, cb, idx, query) {
|
|
|
17331
17339
|
// function processData(data) {
|
|
17332
17340
|
if (data instanceof ArrayBuffer) {
|
|
17333
17341
|
var arr = fixdata(data);
|
|
17334
|
-
var workbook = X.read(btoa(arr), {
|
|
17342
|
+
var workbook = X.read(btoa(arr), {
|
|
17343
|
+
type: 'base64',
|
|
17344
|
+
...alasql.options.excel,
|
|
17345
|
+
...opts,
|
|
17346
|
+
});
|
|
17335
17347
|
} else {
|
|
17336
|
-
var workbook = X.read(data, {
|
|
17348
|
+
var workbook = X.read(data, {
|
|
17349
|
+
type: 'binary',
|
|
17350
|
+
...alasql.options.excel,
|
|
17351
|
+
...opts,
|
|
17352
|
+
});
|
|
17337
17353
|
}
|
|
17338
17354
|
|
|
17339
17355
|
var sheetid;
|
|
@@ -17851,7 +17867,7 @@ async function _databaseExists(name) {
|
|
|
17851
17867
|
|
|
17852
17868
|
if (indexedDB.databases) {
|
|
17853
17869
|
const dbs = await indexedDB.databases();
|
|
17854
|
-
const db = dbs.find(
|
|
17870
|
+
const db = dbs.find(db => db.name === name);
|
|
17855
17871
|
// @ts-ignore
|
|
17856
17872
|
return db || 0;
|
|
17857
17873
|
}
|
|
@@ -17865,7 +17881,7 @@ async function _databaseExists(name) {
|
|
|
17865
17881
|
resolve({name, version: req.result.version});
|
|
17866
17882
|
};
|
|
17867
17883
|
|
|
17868
|
-
req.onupgradeneeded =
|
|
17884
|
+
req.onupgradeneeded = evt => {
|
|
17869
17885
|
evt.target.transaction.abort();
|
|
17870
17886
|
resolve(0);
|
|
17871
17887
|
};
|
|
@@ -17890,7 +17906,7 @@ IDB.showDatabases = function (like, cb) {
|
|
|
17890
17906
|
return;
|
|
17891
17907
|
}
|
|
17892
17908
|
|
|
17893
|
-
indexedDB.databases().then(
|
|
17909
|
+
indexedDB.databases().then(dblist => {
|
|
17894
17910
|
const res = [];
|
|
17895
17911
|
const relike = like && new RegExp(like.value.replace(/\%/g, '.*'), 'g');
|
|
17896
17912
|
|
|
@@ -17905,7 +17921,7 @@ IDB.showDatabases = function (like, cb) {
|
|
|
17905
17921
|
};
|
|
17906
17922
|
|
|
17907
17923
|
IDB.createDatabase = async function (ixdbid, args, ifnotexists, dbid, cb) {
|
|
17908
|
-
const found = await _databaseExists(ixdbid).catch(
|
|
17924
|
+
const found = await _databaseExists(ixdbid).catch(err => {
|
|
17909
17925
|
if (cb) cb(null, err);
|
|
17910
17926
|
throw err;
|
|
17911
17927
|
});
|
|
@@ -17929,7 +17945,7 @@ IDB.createDatabase = async function (ixdbid, args, ifnotexists, dbid, cb) {
|
|
|
17929
17945
|
};
|
|
17930
17946
|
|
|
17931
17947
|
IDB.dropDatabase = async function (ixdbid, ifexists, cb) {
|
|
17932
|
-
const found = await _databaseExists(ixdbid).catch(
|
|
17948
|
+
const found = await _databaseExists(ixdbid).catch(err => {
|
|
17933
17949
|
if (cb) cb(null, err);
|
|
17934
17950
|
throw err;
|
|
17935
17951
|
});
|
|
@@ -17953,7 +17969,7 @@ IDB.dropDatabase = async function (ixdbid, ifexists, cb) {
|
|
|
17953
17969
|
};
|
|
17954
17970
|
|
|
17955
17971
|
IDB.attachDatabase = async function (ixdbid, dbid, args, params, cb) {
|
|
17956
|
-
const found = await _databaseExists(ixdbid).catch(
|
|
17972
|
+
const found = await _databaseExists(ixdbid).catch(err => {
|
|
17957
17973
|
if (cb) cb(null, err);
|
|
17958
17974
|
throw err;
|
|
17959
17975
|
});
|
|
@@ -17988,7 +18004,7 @@ IDB.attachDatabase = async function (ixdbid, dbid, args, params, cb) {
|
|
|
17988
18004
|
|
|
17989
18005
|
IDB.createTable = async function (databaseid, tableid, ifnotexists, cb) {
|
|
17990
18006
|
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
17991
|
-
const found = await _databaseExists(ixdbid).catch(
|
|
18007
|
+
const found = await _databaseExists(ixdbid).catch(err => {
|
|
17992
18008
|
if (cb) cb(null, err);
|
|
17993
18009
|
throw err;
|
|
17994
18010
|
});
|
|
@@ -18009,7 +18025,7 @@ IDB.createTable = async function (databaseid, tableid, ifnotexists, cb) {
|
|
|
18009
18025
|
request.result.close();
|
|
18010
18026
|
if (cb) cb(1);
|
|
18011
18027
|
};
|
|
18012
|
-
request.onerror =
|
|
18028
|
+
request.onerror = evt => {
|
|
18013
18029
|
cb(null, evt);
|
|
18014
18030
|
};
|
|
18015
18031
|
request.onblocked = function (event) {
|
|
@@ -18022,7 +18038,7 @@ IDB.createTable = async function (databaseid, tableid, ifnotexists, cb) {
|
|
|
18022
18038
|
|
|
18023
18039
|
IDB.dropTable = async function (databaseid, tableid, ifexists, cb) {
|
|
18024
18040
|
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18025
|
-
const found = await _databaseExists(ixdbid).catch(
|
|
18041
|
+
const found = await _databaseExists(ixdbid).catch(err => {
|
|
18026
18042
|
if (cb) cb(null, err);
|
|
18027
18043
|
throw err;
|
|
18028
18044
|
});
|
|
@@ -18071,7 +18087,7 @@ IDB.intoTable = function (databaseid, tableid, value, columns, cb) {
|
|
|
18071
18087
|
var db = alasql.databases[databaseid];
|
|
18072
18088
|
var table = db.tables[tableid];
|
|
18073
18089
|
|
|
18074
|
-
request.onupgradeneeded =
|
|
18090
|
+
request.onupgradeneeded = evt => {
|
|
18075
18091
|
evt.target.transaction.abort();
|
|
18076
18092
|
const err = new Error(
|
|
18077
18093
|
`Cannot insert into table "${tableid}" because database "${databaseid}" does not exist`
|
|
@@ -18107,7 +18123,7 @@ IDB.fromTable = function (databaseid, tableid, cb, idx, query) {
|
|
|
18107
18123
|
const ixdbid = alasql.databases[databaseid].ixdbid;
|
|
18108
18124
|
const request = indexedDB.open(ixdbid);
|
|
18109
18125
|
|
|
18110
|
-
request.onupgradeneeded =
|
|
18126
|
+
request.onupgradeneeded = evt => {
|
|
18111
18127
|
evt.target.transaction.abort();
|
|
18112
18128
|
const err = new Error(
|
|
18113
18129
|
`Cannot select from table "${tableid}" because database "${databaseid}" does not exist`
|
|
@@ -18124,7 +18140,7 @@ IDB.fromTable = function (databaseid, tableid, cb, idx, query) {
|
|
|
18124
18140
|
const cursor = cur.result;
|
|
18125
18141
|
if (cursor) {
|
|
18126
18142
|
// if keyPath(columns) is not present then we take the key and value as object.
|
|
18127
|
-
const cursorValue = typeof cursor === Object ? cursor.value : {
|
|
18143
|
+
const cursorValue = typeof cursor === Object ? cursor.value : {[cursor.key]: cursor.value};
|
|
18128
18144
|
res.push(cursorValue);
|
|
18129
18145
|
cursor.continue();
|
|
18130
18146
|
} else {
|
|
@@ -19163,7 +19179,9 @@ var saveAs =
|
|
|
19163
19179
|
blob.type
|
|
19164
19180
|
)
|
|
19165
19181
|
) {
|
|
19166
|
-
return new Blob([String.fromCharCode(0xfeff), blob], {
|
|
19182
|
+
return new Blob([String.fromCharCode(0xfeff), blob], {
|
|
19183
|
+
type: blob.type,
|
|
19184
|
+
});
|
|
19167
19185
|
}
|
|
19168
19186
|
return blob;
|
|
19169
19187
|
},
|