forked from sql-js/sql.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_issue73.js
52 lines (50 loc) · 1.54 KB
/
test_issue73.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
exports.test = function(sql, assert) {
// Create a database
var db = new sql.Database();
// Execute some sql
sqlstr = "CREATE TABLE COMPANY("+
" ID INT PRIMARY KEY NOT NULL,"+
" NAME TEXT NOT NULL,"+
" AGE INT NOT NULL,"+
" ADDRESS CHAR(50),"+
" SALARY REAL"+
" );"+
" CREATE TABLE AUDIT("+
" EMP_ID INT NOT NULL,"+
" ENTRY_DATE TEXT NOT NULL"+
" );"+
" CREATE TRIGGER audit_log AFTER INSERT"+
" ON COMPANY"+
" BEGIN"+
" INSERT INTO AUDIT"+
" (EMP_ID, ENTRY_DATE)"+
" VALUES"+
" (new.ID, '2014-11-10');"+
" END;"+
" INSERT INTO COMPANY VALUES (73,'A',8,'',1200);"+
" SELECT * FROM AUDIT;"+
" INSERT INTO COMPANY VALUES (42,'B',8,'',1600);"+
" SELECT EMP_ID FROM AUDIT ORDER BY EMP_ID";
var res = db.exec(sqlstr);
var expectedResult = [
{
columns : ['EMP_ID','ENTRY_DATE'],
values : [
[73, '2014-11-10']
]
},
{
columns : ['EMP_ID'],
values : [
[42],[73]
]
}
];
assert.deepEqual(res, expectedResult,
"db.exec with a statement that contains a ';'");
};
if (module == require.main) {
var sql = require('../js/sql.js');
var assert = require('assert');
exports.test(sql, assert);
}