-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathalias-tests.js
More file actions
124 lines (118 loc) · 5.48 KB
/
alias-tests.js
File metadata and controls
124 lines (118 loc) · 5.48 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
'use strict';
var Harness = require('./support');
var customer = Harness.defineCustomerTable();
var Sql = require('../../lib');
var sql = new Sql();
sql.setDialect('postgres');
Harness.test({
query: customer.select(customer.name.isNull().as('nameIsNull')),
pg: {
text : 'SELECT ("customer"."name" IS NULL) AS "nameIsNull" FROM "customer"',
string: 'SELECT ("customer"."name" IS NULL) AS "nameIsNull" FROM "customer"'
},
sqlite: {
text : 'SELECT ("customer"."name" IS NULL) AS "nameIsNull" FROM "customer"',
string: 'SELECT ("customer"."name" IS NULL) AS "nameIsNull" FROM "customer"'
},
mysql: {
text : 'SELECT (`customer`.`name` IS NULL) AS `nameIsNull` FROM `customer`',
string: 'SELECT (`customer`.`name` IS NULL) AS `nameIsNull` FROM `customer`'
},
mssql: {
text : 'SELECT ([customer].[name] IS NULL) AS [nameIsNull] FROM [customer]',
string: 'SELECT ([customer].[name] IS NULL) AS [nameIsNull] FROM [customer]'
},
oracle: {
text : 'SELECT ("customer"."name" IS NULL) "nameIsNull" FROM "customer"',
string: 'SELECT ("customer"."name" IS NULL) "nameIsNull" FROM "customer"'
},
params: []
});
Harness.test({
query: customer.select(customer.name.plus(customer.age).as('nameAndAge')).where(customer.age.gt(10).and(customer.age.lt(20))),
pg: {
text : 'SELECT ("customer"."name" + "customer"."age") AS "nameAndAge" FROM "customer" WHERE (("customer"."age" > $1) AND ("customer"."age" < $2))',
string: 'SELECT ("customer"."name" + "customer"."age") AS "nameAndAge" FROM "customer" WHERE (("customer"."age" > 10) AND ("customer"."age" < 20))'
},
sqlite: {
text : 'SELECT ("customer"."name" + "customer"."age") AS "nameAndAge" FROM "customer" WHERE (("customer"."age" > $1) AND ("customer"."age" < $2))',
string: 'SELECT ("customer"."name" + "customer"."age") AS "nameAndAge" FROM "customer" WHERE (("customer"."age" > 10) AND ("customer"."age" < 20))'
},
mysql: {
text : 'SELECT (`customer`.`name` + `customer`.`age`) AS `nameAndAge` FROM `customer` WHERE ((`customer`.`age` > ?) AND (`customer`.`age` < ?))',
string: 'SELECT (`customer`.`name` + `customer`.`age`) AS `nameAndAge` FROM `customer` WHERE ((`customer`.`age` > 10) AND (`customer`.`age` < 20))'
},
mssql: {
text : 'SELECT ([customer].[name] + [customer].[age]) AS [nameAndAge] FROM [customer] WHERE (([customer].[age] > @1) AND ([customer].[age] < @2))',
string: 'SELECT ([customer].[name] + [customer].[age]) AS [nameAndAge] FROM [customer] WHERE (([customer].[age] > 10) AND ([customer].[age] < 20))'
},
oracle: {
text : 'SELECT ("customer"."name" + "customer"."age") "nameAndAge" FROM "customer" WHERE (("customer"."age" > :1) AND ("customer"."age" < :2))',
string: 'SELECT ("customer"."name" + "customer"."age") "nameAndAge" FROM "customer" WHERE (("customer"."age" > 10) AND ("customer"."age" < 20))'
},
params: [10, 20]
});
Harness.test({
query: customer.select(customer.age.between(10, 20).as('ageBetween')),
pg: {
text : 'SELECT ("customer"."age" BETWEEN $1 AND $2) AS "ageBetween" FROM "customer"',
string: 'SELECT ("customer"."age" BETWEEN 10 AND 20) AS "ageBetween" FROM "customer"'
},
sqlite: {
text : 'SELECT ("customer"."age" BETWEEN $1 AND $2) AS "ageBetween" FROM "customer"',
string: 'SELECT ("customer"."age" BETWEEN 10 AND 20) AS "ageBetween" FROM "customer"'
},
mysql: {
text : 'SELECT (`customer`.`age` BETWEEN ? AND ?) AS `ageBetween` FROM `customer`',
string: 'SELECT (`customer`.`age` BETWEEN 10 AND 20) AS `ageBetween` FROM `customer`'
},
mssql: {
text : 'SELECT ([customer].[age] BETWEEN @1 AND @2) AS [ageBetween] FROM [customer]',
string: 'SELECT ([customer].[age] BETWEEN 10 AND 20) AS [ageBetween] FROM [customer]'
},
oracle: {
text : 'SELECT ("customer"."age" BETWEEN :1 AND :2) "ageBetween" FROM "customer"',
string: 'SELECT ("customer"."age" BETWEEN 10 AND 20) "ageBetween" FROM "customer"'
},
params: [10, 20]
});
Harness.test({
query: customer.select(sql.functions.ROUND(customer.age.as('ageBetween'), 2)),
pg: {
text : 'SELECT ROUND("customer"."age", $1) FROM "customer"',
string: 'SELECT ROUND("customer"."age", 2) FROM "customer"'
},
sqlite: {
text : 'SELECT ROUND("customer"."age", $1) FROM "customer"',
string: 'SELECT ROUND("customer"."age", 2) FROM "customer"'
},
mysql: {
text : 'SELECT ROUND(`customer`.`age`, ?) FROM `customer`',
string: 'SELECT ROUND(`customer`.`age`, 2) FROM `customer`'
},
mssql: {
text : 'SELECT ROUND([customer].[age], @1) FROM [customer]',
string: 'SELECT ROUND([customer].[age], 2) FROM [customer]'
},
oracle: {
text : 'SELECT ROUND("customer"."age", :1) FROM "customer"',
string: 'SELECT ROUND("customer"."age", 2) FROM "customer"'
},
params: [2]
});
Harness.test({
query: customer.select(customer.age.notBetween(10, 20).as('ageNotBetween')),
pg: {
text : 'SELECT ("customer"."age" NOT BETWEEN $1 AND $2) AS "ageNotBetween" FROM "customer"',
string: 'SELECT ("customer"."age" NOT BETWEEN 10 AND 20) AS "ageNotBetween" FROM "customer"'
},
sqlite: {
text : 'SELECT ("customer"."age" NOT BETWEEN $1 AND $2) AS "ageNotBetween" FROM "customer"',
string: 'SELECT ("customer"."age" NOT BETWEEN 10 AND 20) AS "ageNotBetween" FROM "customer"'
},
mysql: {
text : 'SELECT (`customer`.`age` NOT BETWEEN ? AND ?) AS `ageNotBetween` FROM `customer`',
string: 'SELECT (`customer`.`age` NOT BETWEEN 10 AND 20) AS `ageNotBetween` FROM `customer`'
},
params: [10, 20]
});