-
Notifications
You must be signed in to change notification settings - Fork 666
/
Copy pathtest385.js
94 lines (83 loc) · 1.69 KB
/
test385.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
var DOMStorage = require('dom-storage');
global.localStorage = new DOMStorage('./test381.json', {
strict: false,
ws: '',
});
}
/*
This sample beased on this article:
http://stackoverflow.com/questions/30442969/group-by-in-angularjs
*/
describe('Test 385 - Nested Search (issue #495)', function () {
it('1. CREATE DATABASE', function (done) {
alasql('CREATE DATABASE test385;USE test385');
done();
});
it('2. Create table issue - one statement', function (done) {
// Source data
var data1 = [
{
_id: '2mA82CTSeeTrvMxfR',
playlists: [
{
name: 'Electro',
songs: [
{
id: 'dMEwEdkoPLw',
name: 'Moe Shop - You Look So Good',
position: '1',
},
{
id: 'S927n1xUkAM',
name: 'Vexento - Magenta',
position: '2',
},
],
},
],
},
];
// Result data
var data2 = [
{
_id: '2mA82CTSeeTrvMxfR',
playlists: [
{
name: 'Electro',
songs: [
{
id: 'dMEwEdkoPLw',
name: 'Moe Shop - You Look So Good',
position: '2',
},
{
id: 'S927n1xUkAM',
name: 'Vexento - Magenta',
position: '1',
},
],
},
],
},
];
alasql('SEARCH /playlists/songs/WHERE(id=$1) SET(position=$2) FROM $0', [
data1,
'S927n1xUkAM',
'1',
]);
alasql('SEARCH /playlists/songs/WHERE(id=$1) SET(position=$2) FROM $0', [
data1,
'dMEwEdkoPLw',
'2',
]);
assert.deepEqual(data1, data2);
done();
});
it('99. DROP DATABASE', function (done) {
alasql('DROP DATABASE test385');
done();
});
});