alasql 0.6.0 → 0.6.4
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/.DS_Store +0 -0
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/nodejs.yml +29 -0
- package/CHANGELOG.md +56 -33
- package/README.md +9 -11
- package/bin/alaserver.js +17 -15
- package/bin/alasql-cli.js +31 -22
- package/dist/alasql-echo.js +10 -8
- package/dist/alasql-prolog.js +29 -18
- package/dist/alasql-worker.js +7 -7
- package/dist/alasql-worker.min.js +2 -2
- package/dist/alasql.fs.js +9228 -9444
- package/dist/alasql.js +1098 -1314
- package/dist/alasql.min.js +2 -2
- package/package.json +17 -24
- package/yarn-error.log +6967 -0
package/.DS_Store
ADDED
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: CI-test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: '*'
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: '*'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
node-version: [10.x, 12.x, 13.x, 14.x]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v2
|
|
20
|
+
- name: Test with Node.js ${{ matrix.node-version }}
|
|
21
|
+
uses: actions/setup-node@v1
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
- run: npx yarn install --frozen-lockfile
|
|
25
|
+
- run: npx prettier src/*.js --list-different || (echo 'Please correct file formatting using `yarn format` and try again.' && exit 1)
|
|
26
|
+
- run: npx yarn test
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,36 +1,58 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### 0.6.4 (24.09.2020)
|
|
3
4
|
|
|
5
|
+
- Add: String and Number objects supported as values
|
|
6
|
+
- Add: `JOIN USING` now supports String and Number objects
|
|
7
|
+
- Fix: File naming when exporting to Exel
|
|
4
8
|
|
|
5
|
-
# 0.6.0 (02.05.2020)
|
|
6
|
-
Add: NULLS FIRST/LAST clause in ORDER BY (#1187)
|
|
7
|
-
Add: Support table/row names starting with numbers
|
|
8
9
|
|
|
10
|
+
### 0.6.2 (31.05.2020)
|
|
9
11
|
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
Add: Composite foreign keys implementation (#1179)
|
|
13
|
-
Fix: Insert's toString() (#1177)
|
|
14
|
-
Fix: DROP Filestorage Database with database name (#1184)
|
|
13
|
+
- Add: Use NOT BETWEEN without parenthesis.
|
|
15
14
|
|
|
16
|
-
## 0.5.8 (27.03.2020)
|
|
17
|
-
Fix: usage of CURRENT_TIMESTAMP (Fix #1174)
|
|
18
15
|
|
|
19
|
-
## 0.5.6 "Bafq" (22.03.2020)
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
### 0.6.1 (20.05.2020)
|
|
18
|
+
|
|
19
|
+
- Add: Use BETWEEN without parenthesis.
|
|
20
|
+
- Fix: Let ADD COLUMN use the given dbtypeid
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## 0.6.0 (02.05.2020)
|
|
25
|
+
|
|
26
|
+
- Add: NULLS FIRST/LAST clause in ORDER BY (#1187)
|
|
27
|
+
- Add: Support table/row names starting with numbers
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### 0.5.9 (26.04.2020)
|
|
32
|
+
|
|
33
|
+
- Add: Composite foreign keys implementation (#1179)
|
|
34
|
+
- Fix: Insert's toString() (#1177)
|
|
35
|
+
- Fix: DROP Filestorage Database with database name (#1184)
|
|
36
|
+
|
|
37
|
+
### 0.5.8 (27.03.2020)
|
|
38
|
+
|
|
39
|
+
- Fix: usage of CURRENT_TIMESTAMP (Fix #1174)
|
|
40
|
+
|
|
41
|
+
### 0.5.6 "Bafq" (22.03.2020)
|
|
42
|
+
|
|
43
|
+
- Add: GroupBy within nested array data set/params (#1167)
|
|
44
|
+
- Fix: Use unknown DB name
|
|
23
45
|
|
|
24
|
-
|
|
46
|
+
### 0.5.5 "Bam" (29.01.2020)
|
|
25
47
|
|
|
26
48
|
- Fix: Typescript typing
|
|
27
49
|
|
|
28
|
-
|
|
50
|
+
### 0.5.4 "Qom" (19.01.2020)
|
|
29
51
|
|
|
30
52
|
- Fix: QUART/MEDIAN/MIN/MAX on number/date/string
|
|
31
53
|
|
|
32
54
|
|
|
33
|
-
|
|
55
|
+
### 0.5.3 "Chabahar" (02.01.2020)
|
|
34
56
|
|
|
35
57
|
- Better: Support csv data from buffer
|
|
36
58
|
- Better: Error message for foreign key constraint fail #1009
|
|
@@ -39,7 +61,8 @@ Fix: Use unknown DB name
|
|
|
39
61
|
- Fix: Drop trigger #1113
|
|
40
62
|
|
|
41
63
|
|
|
42
|
-
|
|
64
|
+
## 0.5.1 "Qazvin" (16.09.2019)
|
|
65
|
+
|
|
43
66
|
- Add: Chain OUTER JOIN's #1105
|
|
44
67
|
- Better: Typescript typings
|
|
45
68
|
- Better: Updated dependencies
|
|
@@ -48,18 +71,18 @@ Fix: Use unknown DB name
|
|
|
48
71
|
- Fix: Pivot function cast for SUM and AVG
|
|
49
72
|
|
|
50
73
|
|
|
51
|
-
|
|
74
|
+
### 0.4.11 "Lawdar" (05.10.2018)
|
|
52
75
|
|
|
53
76
|
* Add: Specified XLSX sheet without knowing the name
|
|
54
77
|
|
|
55
78
|
|
|
56
|
-
|
|
79
|
+
### 0.4.10 "Maoshk" (04.10.2018)
|
|
57
80
|
|
|
58
81
|
|
|
59
82
|
* Add: xlsxml files with multiple sheets
|
|
60
83
|
|
|
61
84
|
|
|
62
|
-
|
|
85
|
+
### 0.4.9 "Alsalfiah" (05.08.2018)
|
|
63
86
|
|
|
64
87
|
* Better: Error message grammar
|
|
65
88
|
* Better: Support for Meteor code standards
|
|
@@ -67,41 +90,41 @@ Fix: Use unknown DB name
|
|
|
67
90
|
* Fix: Handle promise error when reading one line csv files
|
|
68
91
|
* Fix: AUTO_INCREMENT when using local storage
|
|
69
92
|
|
|
70
|
-
|
|
93
|
+
### 0.4.8 "Nafhan" (14.07.2018)
|
|
71
94
|
|
|
72
95
|
* Fix: Error when installing caused by missing cli file in npm
|
|
73
96
|
|
|
74
97
|
|
|
75
|
-
|
|
98
|
+
### 0.4.7 "Tarim" (14.07.2018)
|
|
76
99
|
|
|
77
100
|
* Better: Always find global object
|
|
78
101
|
|
|
79
102
|
|
|
80
|
-
|
|
103
|
+
### 0.4.6 "Rahbah" (14.06.2018)
|
|
81
104
|
|
|
82
105
|
* Better: `Use strict` mode for javascript
|
|
83
106
|
|
|
84
107
|
|
|
85
|
-
|
|
108
|
+
### 0.4.5 "Marib" (24.01.2018)
|
|
86
109
|
|
|
87
110
|
* Fix: Aggregate functions applied to empty sets (#964)
|
|
88
111
|
* Fix: missing ORDER BY direction when calling toString on AST (#970)
|
|
89
112
|
* Fix: Converting the syntax tree back to SQL with multple joins (#972)
|
|
90
113
|
|
|
91
|
-
|
|
114
|
+
### 0.4.4 "Alsowm" (03.12.2017)
|
|
92
115
|
|
|
93
116
|
* Better: Better usage via unpkg.com
|
|
94
117
|
* Better: Better usage via jsdelivr.com
|
|
95
118
|
|
|
96
119
|
|
|
97
|
-
|
|
120
|
+
### 0.4.3 "Hajjah" (05.09.2017)
|
|
98
121
|
|
|
99
122
|
* Update: Removed implicit "any" in definition file
|
|
100
123
|
* Fix: Tabletop reads in empty cells as numeric 0 instead of empty string
|
|
101
124
|
* Fix: DISTINCT on emtpy table produced error
|
|
102
125
|
|
|
103
126
|
|
|
104
|
-
|
|
127
|
+
### 0.4.2 "Baraqish" (17.08.2017)
|
|
105
128
|
|
|
106
129
|
* Added: SQL function LTRIM
|
|
107
130
|
* Added: SQL function RTRIM
|
|
@@ -110,7 +133,7 @@ Fix: Use unknown DB name
|
|
|
110
133
|
* Fix: Use created database id on foreign key check as default database
|
|
111
134
|
|
|
112
135
|
|
|
113
|
-
|
|
136
|
+
### 0.4.1 "Sayhut" (23.07.2017)
|
|
114
137
|
|
|
115
138
|
* Better: Performace on `distinct` selects
|
|
116
139
|
* Better: Hashing for cashed SQLs
|
|
@@ -118,7 +141,7 @@ Fix: Use unknown DB name
|
|
|
118
141
|
* Fix: Select from empty EXCEL
|
|
119
142
|
|
|
120
143
|
|
|
121
|
-
|
|
144
|
+
##0.4.0 "Sanaa" (09.05.2017)
|
|
122
145
|
* **Breaking:** OFFSET will now skip the first N rows in a result set before starting to return any rows (before it would skip N-1)
|
|
123
146
|
* Add: Quartile aggregators (QUART, QUART2, QUART3)
|
|
124
147
|
* Add: Typescript definitoin now supports extensions
|
|
@@ -404,7 +427,7 @@ Minor verison updated to sync lib, Meteor and npm version
|
|
|
404
427
|
### 0.1.2 "Firenze" (06.05.2015 - 07.05.2015)
|
|
405
428
|
* Simple compilation of SEARCH operator
|
|
406
429
|
* SUM(),COUNT(),MIN(),MAX(),FIRST(),LAST() search aggregators
|
|
407
|
-
* # operator, CREATE VERTEX #
|
|
430
|
+
* The # operator, CREATE VERTEX #
|
|
408
431
|
* SEARCH # - start with object
|
|
409
432
|
* SERCH smth # - test for object
|
|
410
433
|
* SEARCH VALUE - leave only one first object in the result
|
|
@@ -454,7 +477,7 @@ Minor verison updated to sync lib, Meteor and npm version
|
|
|
454
477
|
* CREATE CLASS
|
|
455
478
|
* INSERT INTO class
|
|
456
479
|
* INSERT INTO class returns inserted value
|
|
457
|
-
* # operator
|
|
480
|
+
* The # operator
|
|
458
481
|
* Classes support
|
|
459
482
|
* Tests with SEARCH syntax and tests for CREATE EDGE and CREATE VERTES
|
|
460
483
|
* Fixed bug with leaking to global.key
|
|
@@ -880,11 +903,11 @@ Minor verison updated to sync lib, Meteor and npm version
|
|
|
880
903
|
* Where optimization
|
|
881
904
|
* New names for fields => columns and recs => data
|
|
882
905
|
|
|
883
|
-
|
|
906
|
+
### 0.0.5 (30.10.2014)
|
|
884
907
|
|
|
885
908
|
* Changed order of LIMIT and ORDER BY processing
|
|
886
909
|
|
|
887
|
-
|
|
910
|
+
### Version 0.0.4 (28.10.2014-29.10.2014)
|
|
888
911
|
|
|
889
912
|
* Added /test/main.html mocha browser tests
|
|
890
913
|
* Added PERFORMANCE.md and perf.html tests
|
|
@@ -894,7 +917,7 @@ Minor verison updated to sync lib, Meteor and npm version
|
|
|
894
917
|
* Remove generation of recs after select in case of group by (for memory optimization)
|
|
895
918
|
* Added conversion for type MONEY for INSERT statement
|
|
896
919
|
|
|
897
|
-
|
|
920
|
+
### Versions 0.0.1 - 0.0.3 (25.10.2014-27.10.2014)
|
|
898
921
|
|
|
899
922
|
* First version of Alasql
|
|
900
923
|
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ _AlaSQL is an open source project used on more than two million page views per m
|
|
|
3
3
|
_Have a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask?tags=AlaSQL) using the "alasql" tag._
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
[](https://github.com/agershun/alasql/actions)
|
|
7
7
|
[](https://npm-stat.com/charts.html?package=alasql)
|
|
8
8
|
[](http://open-oss.com)
|
|
9
9
|
[](https://www.npmjs.com/package/alasql)
|
|
@@ -105,8 +105,10 @@ __If you are familiar with SQL it should come as no surprise that proper use of
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
```bash
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
yarn add alasql # yarn
|
|
109
|
+
|
|
110
|
+
npm install alasql # npm
|
|
111
|
+
|
|
110
112
|
npm install -g alasql # global installation for command line tools
|
|
111
113
|
```
|
|
112
114
|
|
|
@@ -114,7 +116,7 @@ For the browser: include [alasql.min.js](https://cdn.jsdelivr.net/npm/alasql)
|
|
|
114
116
|
|
|
115
117
|
|
|
116
118
|
```html
|
|
117
|
-
<script src="https://cdn.jsdelivr.net/npm/alasql@0.
|
|
119
|
+
<script src="https://cdn.jsdelivr.net/npm/alasql@0.6"></script>
|
|
118
120
|
```
|
|
119
121
|
|
|
120
122
|
|
|
@@ -142,17 +144,13 @@ Other links:
|
|
|
142
144
|
**All contributions are extremely welcome and greatly appreciated(!)** -
|
|
143
145
|
The project has never received any funding and is based on unpaid voluntary work: [We really (really) love pull requests](https://github.com/agershun/alasql/blob/develop/CONTRIBUTING.md)
|
|
144
146
|
|
|
145
|
-
AlaSQL project
|
|
146
|
-
Please, submit any bugs and suggestions [as an issue](https://github.com/agershun/alasql/issues/new).
|
|
147
|
-
|
|
148
|
-
[](https://github.com/agershun/alasql/issues?q=is%3Aissue+is%3Aopen+label%3A%22%21+Bug%22)
|
|
149
|
-
|
|
147
|
+
The AlaSQL project depends on your contribution of code and <s>may</s> have [bugs](https://github.com/agershun/alasql/labels/%21%20Bug). So please, submit any bugs and suggestions [as an issue](https://github.com/agershun/alasql/issues/new).
|
|
150
148
|
|
|
151
|
-
|
|
149
|
+
Please check out the [limitations of the library](https://github.com/agershun/alasql#limitations).
|
|
152
150
|
|
|
153
151
|
## Performance
|
|
154
152
|
|
|
155
|
-
AlaSQL is designed for speed
|
|
153
|
+
AlaSQL is designed for speed and includes some of the classic SQL engine optimizations:
|
|
156
154
|
|
|
157
155
|
* Queries are cached as compiled functions
|
|
158
156
|
* Joined tables are pre-indexed
|
package/bin/alaserver.js
CHANGED
|
@@ -8,21 +8,23 @@
|
|
|
8
8
|
var alasql = require('alasql');
|
|
9
9
|
var http = require('http');
|
|
10
10
|
var url = require('url');
|
|
11
|
-
var port = (process.argv[2] || 1337)|0;
|
|
12
|
-
if(!port) {
|
|
13
|
-
throw new Error('Wrong port number '+process.argv[3]);
|
|
11
|
+
var port = (process.argv[2] || 1337) | 0;
|
|
12
|
+
if (!port) {
|
|
13
|
+
throw new Error('Wrong port number ' + process.argv[3]);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
http
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
http
|
|
17
|
+
.createServer(function (req, res) {
|
|
18
|
+
var sql = decodeURI(url.parse(req.url).search).substr(1);
|
|
19
|
+
var a = '';
|
|
20
|
+
try {
|
|
21
|
+
a = alasql(sql);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
a = err.toString();
|
|
24
|
+
}
|
|
25
|
+
res.writeHead(200, {'Content-Type': 'application/json'});
|
|
26
|
+
res.end(JSON.stringify(a));
|
|
27
|
+
})
|
|
28
|
+
.listen(port, '127.0.0.1');
|
|
27
29
|
|
|
28
|
-
console.log('Server running at http://127.0.0.1:'+port+'/');
|
|
30
|
+
console.log('Server running at http://127.0.0.1:' + port + '/');
|
package/bin/alasql-cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
//
|
|
3
3
|
// Command line interface for Alasql
|
|
4
4
|
// Version: 0.2.2
|
|
5
5
|
// Date: 28.07.2015
|
|
@@ -12,39 +12,46 @@ let fs = require('fs');
|
|
|
12
12
|
let stdin = process.openStdin();
|
|
13
13
|
let yargs = require('yargs')
|
|
14
14
|
.strict()
|
|
15
|
-
.usage(
|
|
15
|
+
.usage(
|
|
16
|
+
'AlaSQL command-line utility (version ' +
|
|
17
|
+
alasql.version +
|
|
18
|
+
')\n\nUsage: $0 [options] [sql] [params]'
|
|
19
|
+
)
|
|
16
20
|
|
|
17
|
-
.example('$0 "sql-statement"', 'Run SQL statement and output result as JSON')
|
|
21
|
+
.example('$0 "sql-statement"', 'Run SQL statement and output result as JSON')
|
|
18
22
|
.example('')
|
|
19
|
-
.example(
|
|
23
|
+
.example("$0 'value of select 2+?' 40", 'Outputs 42')
|
|
20
24
|
.example('')
|
|
21
|
-
.example(
|
|
25
|
+
.example("$0 'select count(*) from txt()' < city.txt", 'Count lines in city.txt')
|
|
22
26
|
.example('')
|
|
23
|
-
.example(
|
|
27
|
+
.example(
|
|
28
|
+
'$0 \'select * into xlsx("city.xlsx") from txt("city.txt")\'',
|
|
29
|
+
'Convert from txt to xlsx'
|
|
30
|
+
)
|
|
24
31
|
.example('')
|
|
25
32
|
.example('$0 --file file.sql France 1960', 'Run SQL from file with 2 parameters')
|
|
26
33
|
|
|
27
|
-
.version('v', 'Echo AlaSQL version', alasql.version)
|
|
34
|
+
.version('v', 'Echo AlaSQL version', alasql.version)
|
|
28
35
|
.alias('v', 'version')
|
|
29
36
|
|
|
30
|
-
.boolean('m')
|
|
37
|
+
.boolean('m')
|
|
31
38
|
.describe('m', 'Minify json output')
|
|
32
39
|
.alias('m', 'minify')
|
|
33
40
|
|
|
34
|
-
.describe('f', 'Load SQL from file')
|
|
41
|
+
.describe('f', 'Load SQL from file')
|
|
35
42
|
.alias('f', 'file')
|
|
36
43
|
.nargs('f', 1)
|
|
37
44
|
.normalize('f')
|
|
38
45
|
|
|
39
|
-
.help('h')
|
|
46
|
+
.help('h')
|
|
40
47
|
.alias('h', 'help')
|
|
41
48
|
|
|
42
|
-
.epilog('\nMore information about the library: www.alasql.org')
|
|
49
|
+
.epilog('\nMore information about the library: www.alasql.org');
|
|
43
50
|
|
|
44
51
|
let argv = yargs.argv;
|
|
45
52
|
let sql = '';
|
|
46
53
|
let params = [];
|
|
47
|
-
let pipedData = ''
|
|
54
|
+
let pipedData = '';
|
|
48
55
|
stdin.on('data', function (chunk) {
|
|
49
56
|
pipedData += chunk;
|
|
50
57
|
});
|
|
@@ -67,7 +74,6 @@ if (argv.f) {
|
|
|
67
74
|
|
|
68
75
|
sql = fs.readFileSync(argv.f, 'utf8').toString();
|
|
69
76
|
execute(sql, argv._);
|
|
70
|
-
|
|
71
77
|
} else {
|
|
72
78
|
sql = argv._.shift() || '';
|
|
73
79
|
|
|
@@ -90,9 +96,8 @@ stdin.on('end', function () {
|
|
|
90
96
|
* @returns {null} Result will be printet to console.log
|
|
91
97
|
*/
|
|
92
98
|
function execute(sql, params) {
|
|
93
|
-
|
|
94
99
|
if (0 === sql.trim().length) {
|
|
95
|
-
console.error(
|
|
100
|
+
console.error('\nNo SQL to process\n');
|
|
96
101
|
yargs.showHelp();
|
|
97
102
|
process.exit(1);
|
|
98
103
|
}
|
|
@@ -100,23 +105,28 @@ function execute(sql, params) {
|
|
|
100
105
|
for (var i = 1; i < params.length; i++) {
|
|
101
106
|
var a = params[i];
|
|
102
107
|
if (a[0] !== '"' && a[0] !== "'") {
|
|
103
|
-
if (+a == a) {
|
|
108
|
+
if (+a == a) {
|
|
109
|
+
// jshint ignore:line
|
|
104
110
|
params[i] = +a;
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
|
|
109
|
-
alasql
|
|
115
|
+
alasql
|
|
116
|
+
.promise(sql, params)
|
|
110
117
|
.then(function (res) {
|
|
111
118
|
if (!alasql.options.stdout) {
|
|
112
119
|
console.log(formatOutput(res));
|
|
113
120
|
}
|
|
114
121
|
process.exit(0);
|
|
115
|
-
})
|
|
122
|
+
})
|
|
123
|
+
.catch(function (err) {
|
|
116
124
|
let errorJsonObj = JSON.parse(JSON.stringify(err, Object.getOwnPropertyNames(err)));
|
|
117
|
-
console.error(
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
console.error(
|
|
126
|
+
formatOutput({
|
|
127
|
+
error: errorJsonObj,
|
|
128
|
+
})
|
|
129
|
+
);
|
|
120
130
|
process.exit(1);
|
|
121
131
|
});
|
|
122
132
|
}
|
|
@@ -138,7 +148,6 @@ function isDirectory(filePath) {
|
|
|
138
148
|
return isDir;
|
|
139
149
|
}
|
|
140
150
|
|
|
141
|
-
|
|
142
151
|
/**
|
|
143
152
|
* Format output
|
|
144
153
|
*
|
package/dist/alasql-echo.js
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var yy = alasql.yy;
|
|
4
4
|
|
|
5
|
-
yy.Echo = function (params) {
|
|
6
|
-
yy.
|
|
7
|
-
|
|
5
|
+
yy.Echo = function (params) {
|
|
6
|
+
return yy.extend(this, params);
|
|
7
|
+
};
|
|
8
|
+
yy.Echo.prototype.toString = function () {
|
|
9
|
+
var s = 'TEST ' + this.expr.toString();
|
|
8
10
|
return s;
|
|
9
|
-
}
|
|
11
|
+
};
|
|
10
12
|
|
|
11
13
|
yy.Echo.prototype.execute = function (databaseid, params, cb) {
|
|
12
|
-
// var self = this;
|
|
14
|
+
// var self = this;
|
|
13
15
|
// console.log(76336,this.expr.toJS());
|
|
14
|
-
var fn = new Function('params, alasql','return '+this.expr.toJS());
|
|
16
|
+
var fn = new Function('params, alasql', 'return ' + this.expr.toJS());
|
|
15
17
|
var res = fn(params, alasql);
|
|
16
|
-
if(cb) res = cb(res);
|
|
18
|
+
if (cb) res = cb(res);
|
|
17
19
|
return res;
|
|
18
|
-
}
|
|
20
|
+
};
|
package/dist/alasql-prolog.js
CHANGED
|
@@ -2,39 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
var yy = alasql.yy;
|
|
4
4
|
|
|
5
|
-
yy.Term = function (params) {
|
|
6
|
-
yy.
|
|
5
|
+
yy.Term = function (params) {
|
|
6
|
+
return yy.extend(this, params);
|
|
7
|
+
};
|
|
8
|
+
yy.Term.prototype.toString = function () {
|
|
7
9
|
var s = this.termid;
|
|
8
|
-
if(this.args && this.args.length > 0) {
|
|
9
|
-
s +=
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
if (this.args && this.args.length > 0) {
|
|
11
|
+
s +=
|
|
12
|
+
'(' +
|
|
13
|
+
this.args.map(function (arg) {
|
|
14
|
+
return arg.toString();
|
|
15
|
+
}) +
|
|
16
|
+
')';
|
|
12
17
|
}
|
|
13
18
|
return s;
|
|
14
19
|
};
|
|
15
20
|
|
|
16
|
-
yy.AddRule = function (params) {
|
|
17
|
-
yy.
|
|
21
|
+
yy.AddRule = function (params) {
|
|
22
|
+
return yy.extend(this, params);
|
|
23
|
+
};
|
|
24
|
+
yy.AddRule.prototype.toString = function () {
|
|
18
25
|
var s = '';
|
|
19
|
-
if(this.left) s += this.left.toString();
|
|
26
|
+
if (this.left) s += this.left.toString();
|
|
20
27
|
s += ':-';
|
|
21
|
-
s += this.right
|
|
28
|
+
s += this.right
|
|
29
|
+
.map(function (r) {
|
|
30
|
+
return r.toString();
|
|
31
|
+
})
|
|
32
|
+
.join(',');
|
|
22
33
|
return s;
|
|
23
34
|
};
|
|
24
35
|
|
|
25
36
|
yy.AddRule.prototype.execute = function (databaseid, params, cb) {
|
|
26
|
-
// var self = this;
|
|
27
|
-
// console.log(this.expr.toJS());
|
|
28
|
-
// var fn = new Function('params, alasql','return '+this.expr.toJS());
|
|
29
|
-
// var res = fn(params, alasql);
|
|
37
|
+
// var self = this;
|
|
38
|
+
// console.log(this.expr.toJS());
|
|
39
|
+
// var fn = new Function('params, alasql','return '+this.expr.toJS());
|
|
40
|
+
// var res = fn(params, alasql);
|
|
30
41
|
var res = 1;
|
|
31
42
|
var objects = alasql.databases[databaseid].objects;
|
|
32
43
|
var rule = {};
|
|
33
|
-
if(!this.left) {
|
|
34
|
-
this.right.forEach(function(term){
|
|
44
|
+
if (!this.left) {
|
|
45
|
+
this.right.forEach(function (term) {
|
|
35
46
|
rule.$class = term.termid;
|
|
36
47
|
});
|
|
37
48
|
}
|
|
38
|
-
if(cb) res = cb(res);
|
|
49
|
+
if (cb) res = cb(res);
|
|
39
50
|
return res;
|
|
40
|
-
};
|
|
51
|
+
};
|
package/dist/alasql-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v0.6.
|
|
1
|
+
//! AlaSQL v0.6.4-develop-2311b55fundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 0.6.
|
|
4
|
+
@version 0.6.4-develop-2311b55fundefined
|
|
5
5
|
|
|
6
6
|
AlaSQL - JavaScript SQL database
|
|
7
7
|
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
|
|
@@ -160,12 +160,12 @@ if (!alasql) {
|
|
|
160
160
|
throw new Error('alasql was not found');
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
alasql.worker = function() {
|
|
163
|
+
alasql.worker = function () {
|
|
164
164
|
throw new Error('Can find webworker in this enviroment');
|
|
165
165
|
};
|
|
166
166
|
|
|
167
167
|
if (typeof Worker !== 'undefined') {
|
|
168
|
-
alasql.worker = function(path, paths, cb) {
|
|
168
|
+
alasql.worker = function (path, paths, cb) {
|
|
169
169
|
// var path;
|
|
170
170
|
if (path === true) {
|
|
171
171
|
path = undefined;
|
|
@@ -203,14 +203,14 @@ if (typeof Worker !== 'undefined') {
|
|
|
203
203
|
var blob = new Blob([js], {type: 'text/plain'});
|
|
204
204
|
alasql.webworker = new Worker(URL.createObjectURL(blob));
|
|
205
205
|
|
|
206
|
-
alasql.webworker.onmessage = function(event) {
|
|
206
|
+
alasql.webworker.onmessage = function (event) {
|
|
207
207
|
var id = event.data.id;
|
|
208
208
|
|
|
209
209
|
alasql.buffer[id](event.data.data);
|
|
210
210
|
delete alasql.buffer[id];
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
-
alasql.webworker.onerror = function(e) {
|
|
213
|
+
alasql.webworker.onerror = function (e) {
|
|
214
214
|
throw e;
|
|
215
215
|
};
|
|
216
216
|
|
|
@@ -218,7 +218,7 @@ if (typeof Worker !== 'undefined') {
|
|
|
218
218
|
var sql =
|
|
219
219
|
'REQUIRE ' +
|
|
220
220
|
paths
|
|
221
|
-
.map(function(p) {
|
|
221
|
+
.map(function (p) {
|
|
222
222
|
return '"' + p + '"';
|
|
223
223
|
})
|
|
224
224
|
.join(',');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
//! AlaSQL v0.6.
|
|
2
|
-
!function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function a(r,e,t){"function"==typeof(e=e||[])&&(scope=t,t=e,e=[]),"object"!=typeof e&&(e=[e]);var o=a.lastid++;a.buffer[o]=t,a.webworker.postMessage({id:o,sql:r,params:e})}if(a.options={},a.options.progress=function(){},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)},a.promise=function(){throw new Error("Please include a Promise/A+ library")},"undefined"!=typeof Promise
|
|
1
|
+
//! AlaSQL v0.6.4-develop-2311b55fundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
|
|
2
|
+
!function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function a(r,e,t){"function"==typeof(e=e||[])&&(scope=t,t=e,e=[]),"object"!=typeof e&&(e=[e]);var o=a.lastid++;a.buffer[o]=t,a.webworker.postMessage({id:o,sql:r,params:e})}var i;if(a.options={},a.options.progress=function(){},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)},a.promise=function(){throw new Error("Please include a Promise/A+ library")},"undefined"!=typeof Promise&&(i=function(r,e,n,s){return new Promise(function(t,o){a(r,e,function(r,e){e?o(e):(n&&s&&!1!==a.options.progress&&a.options.progress(n,s),t(r))})})},a.promise=function(r,e){if("undefined"==typeof Promise)throw new Error("Please include a Promise/A+ library");if("string"==typeof r)return i(r,e);if(!isArray(r)||r.length<1||void 0!==e)throw new Error("Error in .promise parameters");return function(r){if(!(r.length<1)){for(var e,t,o,n=[],s=0;s<r.length;s++){if("string"==typeof(e=r[s])&&(e=[e]),!isArray(e)||e.length<1||2<e.length)throw new Error("Error in .promise parameter");t=e[0],o=e[1]||void 0,n.push(i(t,o,s,r.length))}return Promise.all(n)}}(r)}),!(a=a||!1))throw new Error("alasql was not found");return a.worker=function(){throw new Error("Can find webworker in this enviroment")},"undefined"!=typeof Worker&&(a.worker=function(r,e,t){if(!0===r&&(r=void 0),void 0===r)for(var o=document.getElementsByTagName("script"),n=0;n<o.length;n++){if("alasql-worker.js"===o[n].src.substr(-16).toLowerCase()){r=o[n].src.substr(0,o[n].src.length-16)+"alasql.js";break}if("alasql-worker.min.js"===o[n].src.substr(-20).toLowerCase()){r=o[n].src.substr(0,o[n].src.length-20)+"alasql.min.js";break}if("alasql.js"===o[n].src.substr(-9).toLowerCase()){r=o[n].src;break}if("alasql.min.js"===o[n].src.substr(-13).toLowerCase()){r=o[n].src.substr(0,o[n].src.length-13)+"alasql.min.js";break}}if(void 0===r)throw new Error("Path to alasql.js is not specified");if(!1!==r){var s="importScripts('";s+=r,s+="');self.onmessage = function(event) {alasql(event.data.sql,event.data.params, function(data){postMessage({id:event.data.id, data:data});});}";var i=new Blob([s],{type:"text/plain"});a.webworker=new Worker(URL.createObjectURL(i)),a.webworker.onmessage=function(r){var e=r.data.id;a.buffer[e](r.data.data),delete a.buffer[e]},a.webworker.onerror=function(r){throw r},1<arguments.length&&a("REQUIRE "+e.map(function(r){return'"'+r+'"'}).join(","),[],t)}else if(!1===r)return void delete a.webworker}),a.lastid=0,a.buffer={},a.worker(),a});
|