forked from brianc/node-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary-clause-tests.js
More file actions
103 lines (97 loc) · 5.01 KB
/
binary-clause-tests.js
File metadata and controls
103 lines (97 loc) · 5.01 KB
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
101
102
103
'use strict';
var Harness = require('./support');
var customer = Harness.defineCustomerTable();
var customerAlias = Harness.defineCustomerAliasTable();
var post = Harness.definePostTable();
Harness.test({
query: customer.select(customer.name.plus(customer.age)),
pg: {
text : 'SELECT ("customer"."name" + "customer"."age") FROM "customer"',
string: 'SELECT ("customer"."name" + "customer"."age") FROM "customer"'
},
sqlite: {
text : 'SELECT ("customer"."name" + "customer"."age") FROM "customer"',
string: 'SELECT ("customer"."name" + "customer"."age") FROM "customer"'
},
mysql: {
text : 'SELECT (`customer`.`name` + `customer`.`age`) FROM `customer`',
string: 'SELECT (`customer`.`name` + `customer`.`age`) FROM `customer`'
},
mssql: {
text : 'SELECT ([customer].[name] + [customer].[age]) FROM [customer]',
string: 'SELECT ([customer].[name] + [customer].[age]) FROM [customer]'
},
oracle: {
text : 'SELECT ("customer"."name" + "customer"."age") FROM "customer"',
string: 'SELECT ("customer"."name" + "customer"."age") FROM "customer"'
},
params: []
});
Harness.test({
query: customerAlias.select(customerAlias.name_alias.plus(customerAlias.age_alias)),
pg: {
text : 'SELECT ("customer"."name" + "customer"."age") FROM "customer"',
string: 'SELECT ("customer"."name" + "customer"."age") FROM "customer"'
},
sqlite: {
text : 'SELECT ("customer"."name" + "customer"."age") FROM "customer"',
string: 'SELECT ("customer"."name" + "customer"."age") FROM "customer"'
},
mysql: {
text : 'SELECT (`customer`.`name` + `customer`.`age`) FROM `customer`',
string: 'SELECT (`customer`.`name` + `customer`.`age`) FROM `customer`'
},
mssql: {
text : 'SELECT ([customer].[name] + [customer].[age]) FROM [customer]',
string: 'SELECT ([customer].[name] + [customer].[age]) FROM [customer]'
},
params: []
});
Harness.test({
query: post.select(post.content.plus('!')).where(post.userId. in (customer.subQuery().select(customer.id))),
pg: {
text : 'SELECT ("post"."content" + $1) FROM "post" WHERE ("post"."userId" IN (SELECT "customer"."id" FROM "customer"))',
string: 'SELECT ("post"."content" + \'!\') FROM "post" WHERE ("post"."userId" IN (SELECT "customer"."id" FROM "customer"))'
},
sqlite: {
text : 'SELECT ("post"."content" + $1) FROM "post" WHERE ("post"."userId" IN (SELECT "customer"."id" FROM "customer"))',
string: 'SELECT ("post"."content" + \'!\') FROM "post" WHERE ("post"."userId" IN (SELECT "customer"."id" FROM "customer"))'
},
mysql: {
text : 'SELECT (`post`.`content` + ?) FROM `post` WHERE (`post`.`userId` IN (SELECT `customer`.`id` FROM `customer`))',
string: 'SELECT (`post`.`content` + \'!\') FROM `post` WHERE (`post`.`userId` IN (SELECT `customer`.`id` FROM `customer`))'
},
mssql: {
text : 'SELECT ([post].[content] + @1) FROM [post] WHERE ([post].[userId] IN (SELECT [customer].[id] FROM [customer]))',
string: 'SELECT ([post].[content] + \'!\') FROM [post] WHERE ([post].[userId] IN (SELECT [customer].[id] FROM [customer]))'
},
oracle: {
text : 'SELECT ("post"."content" + :1) FROM "post" WHERE ("post"."userId" IN (SELECT "customer"."id" FROM "customer"))',
string: 'SELECT ("post"."content" + \'!\') FROM "post" WHERE ("post"."userId" IN (SELECT "customer"."id" FROM "customer"))'
},
params: ['!']
});
Harness.test({
query: post.select(post.id.plus(': ').plus(post.content)).where(post.userId.notIn(customer.subQuery().select(customer.id))),
pg: {
text : 'SELECT (("post"."id" + $1) + "post"."content") FROM "post" WHERE ("post"."userId" NOT IN (SELECT "customer"."id" FROM "customer"))',
string: 'SELECT (("post"."id" + \': \') + "post"."content") FROM "post" WHERE ("post"."userId" NOT IN (SELECT "customer"."id" FROM "customer"))'
},
sqlite: {
text : 'SELECT (("post"."id" + $1) + "post"."content") FROM "post" WHERE ("post"."userId" NOT IN (SELECT "customer"."id" FROM "customer"))',
string: 'SELECT (("post"."id" + \': \') + "post"."content") FROM "post" WHERE ("post"."userId" NOT IN (SELECT "customer"."id" FROM "customer"))'
},
mysql: {
text : 'SELECT ((`post`.`id` + ?) + `post`.`content`) FROM `post` WHERE (`post`.`userId` NOT IN (SELECT `customer`.`id` FROM `customer`))',
string: 'SELECT ((`post`.`id` + \': \') + `post`.`content`) FROM `post` WHERE (`post`.`userId` NOT IN (SELECT `customer`.`id` FROM `customer`))'
},
mssql: {
text : 'SELECT (([post].[id] + @1) + [post].[content]) FROM [post] WHERE ([post].[userId] NOT IN (SELECT [customer].[id] FROM [customer]))',
string: 'SELECT (([post].[id] + \': \') + [post].[content]) FROM [post] WHERE ([post].[userId] NOT IN (SELECT [customer].[id] FROM [customer]))'
},
oracle: {
text : 'SELECT (("post"."id" + :1) + "post"."content") FROM "post" WHERE ("post"."userId" NOT IN (SELECT "customer"."id" FROM "customer"))',
string: 'SELECT (("post"."id" + \': \') + "post"."content") FROM "post" WHERE ("post"."userId" NOT IN (SELECT "customer"."id" FROM "customer"))'
},
params: [': ']
});