-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy path1_mssql.js
63 lines (60 loc) · 1.56 KB
/
1_mssql.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
'use strict';
var jsonSql = require('../../lib')({
dialect: 'mssql',
namedValues: false
});
var expect = require('chai').expect;
describe('MSSQL dialect', function() {
describe('limit', function() {
it('should be ok with `limit` property', function() {
var result = jsonSql.build({
table: 'test',
fields: ['user'],
limit: 1,
condition: {
'name': {$eq: 'test'}
}
});
expect(result.query).to.be.equal('select top(1) "user" from "test" where "name" = $1;');
});
it('should be ok with `limit` and `offset` properties', function() {
var result = jsonSql.build({
table: 'test',
fields: ['user'],
limit: 4,
offset: 2,
condition: {
'name': {$eq: 'test'}
}
});
expect(result.query).to.be.equal('select "user" from "test" where "name" = $1 order by 1' +
' offset 2 rows fetch next 4 rows only;');
});
});
describe('returning', function() {
it('should be ok with `remove` type', function() {
var result = jsonSql.build({
type: 'remove',
table: 'test',
returning: ['DELETED.*'],
condition: {
Description: {$eq: 'test'}
}
});
expect(result.query).to.be.equal('delete from "test" output "DELETED".* where ' +
'"Description" = $1;');
});
it('should be ok with `insert` type', function() {
var result = jsonSql.build({
type: 'insert',
table: 'test',
returning: ['INSERTED.*'],
values: {
Description: 'test',
}
});
expect(result.query).to.be.equal('insert into "test" ("Description") output ' +
'"INSERTED".* values ($1);');
});
});
});