-
Notifications
You must be signed in to change notification settings - Fork 4
/
test-remove.js
100 lines (79 loc) · 2.64 KB
/
test-remove.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
95
96
97
98
99
100
const test = require('test')
test.setup()
var common = require('../common')
var assert = require('assert')
function shared(queryOptions) {
assert.equal(
common.Remove(queryOptions).from('table1').build(),
'delete from `table1`'
)
assert.equal(
common.Remove(queryOptions).from('table1').where({ col: 1 }).build(),
"delete from `table1` where `col` = 1"
)
assert.equal(
common.Remove(queryOptions).from('table1').where({ col1: 1 }, { col2: 2 }).build(),
"delete from `table1` where `col1` = 1 and `col2` = 2"
)
assert.equal(
common.Remove(queryOptions).from('table1').where({ or: [{ col: 1 }, { col: 2 }] }).build(),
// 'delete from `table1` where ((`col` = 1) OR (`col` = 2))'
"delete from `table1` where ((`col` = 1) or (`col` = 2))"
)
assert.equal(
common.Remove(queryOptions).from('table1').limit(10).build(),
'delete from `table1` LIMIT 10'
)
assert.equal(
common.Remove(queryOptions).from('table1').limit(10).offset(3).build(),
'delete from `table1` LIMIT 10 OFFSET 3'
)
assert.equal(
common.Remove(queryOptions).from('table1').order('col').limit(5).build(),
'delete from `table1` ORDER BY `col` ASC LIMIT 5'
)
assert.equal(
common.Remove(queryOptions).from('table1').order('col1', 'A').order('col2', 'Z').limit(5).build(),
'delete from `table1` ORDER BY `col1` ASC, `col2` DESC LIMIT 5'
)
}
describe('remove', () => {
it('remove - mysql', () => {
const queryOptions = { dialect: 'mysql' };
shared(queryOptions)
});
it('remove - sqlite', () => {
const queryOptions = { dialect: 'sqlite' };
shared(queryOptions)
});
xit('remove - mssql', () => {
const queryOptions = { dialect: 'mssql' };
assert.equal(
common.Remove(queryOptions).from('table1').build(),
)
assert.equal(
common.Remove(queryOptions).from('table1').where({ col: 1 }).build(),
)
assert.equal(
common.Remove(queryOptions).from('table1').where({ col1: 1 }, { col2: 2 }).build(),
)
assert.equal(
common.Remove(queryOptions).from('table1').where({ or: [{ col: 1 }, { col: 2 }] }).build(),
)
assert.equal(
common.Remove(queryOptions).from('table1').limit(10).build(),
)
assert.equal(
common.Remove(queryOptions).from('table1').limit(10).offset(3).build(),
)
assert.equal(
common.Remove(queryOptions).from('table1').order('col').limit(5).build(),
)
assert.equal(
common.Remove(queryOptions).from('table1').order('col1', 'A').order('col2', 'Z').limit(5).build(),
)
});
})
if (require.main === module) {
test.run(console.DEBUG)
}