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
30 lines (26 loc) · 1.58 KB
/
binary-clause-tests.js
File metadata and controls
30 lines (26 loc) · 1.58 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
'use strict';
var Harness = require('./support');
var customer = Harness.defineCustomerTable();
var post = Harness.definePostTable();
var Table = require(__dirname + '/../../lib/table');
Harness.test({
query : customer.select(customer.name.add(customer.age)),
pg : 'SELECT ("customer"."name" + "customer"."age") FROM "customer"',
sqlite: 'SELECT ("customer"."name" + "customer"."age") FROM "customer"',
mysql : 'SELECT (`customer`.`name` + `customer`.`age`) FROM `customer`',
params: []
});
Harness.test({
query : post.select(post.content.add('!')).where(post.userId.in(customer.subQuery().select(customer.id))),
pg : 'SELECT ("post"."content" + $1) FROM "post" WHERE ("post"."userId" IN (SELECT "customer"."id" FROM "customer"))',
sqlite: 'SELECT ("post"."content" + $1) FROM "post" WHERE ("post"."userId" IN (SELECT "customer"."id" FROM "customer"))',
mysql : 'SELECT (`post`.`content` + ?) FROM `post` WHERE (`post`.`userId` IN (SELECT `customer`.`id` FROM `customer`))',
params: ['!']
});
Harness.test({
query : post.select(post.id.add(': ').add(post.content)).where(post.userId.notIn(customer.subQuery().select(customer.id))),
pg : 'SELECT (("post"."id" + $1) + "post"."content") FROM "post" WHERE ("post"."userId" NOT IN (SELECT "customer"."id" FROM "customer"))',
sqlite : 'SELECT (("post"."id" + $1) + "post"."content") FROM "post" WHERE ("post"."userId" NOT IN (SELECT "customer"."id" FROM "customer"))',
mysql : 'SELECT ((`post`.`id` + ?) + `post`.`content`) FROM `post` WHERE (`post`.`userId` NOT IN (SELECT `customer`.`id` FROM `customer`))',
params : [': ']
});