forked from brianc/node-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubfield-tests.js
More file actions
42 lines (36 loc) · 1.21 KB
/
subfield-tests.js
File metadata and controls
42 lines (36 loc) · 1.21 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
'use strict';
var Harness = require('./support');
var customer = Harness.defineCustomerCompositeTable();
var Sql = require('../../lib').setDialect('postgres');
Harness.test({
query: customer.select(customer.info.subfields.age),
pg: {
text : 'SELECT ("customer"."info")."age" FROM "customer"',
string: 'SELECT ("customer"."info")."age" FROM "customer"'
},
params: []
});
Harness.test({
query: customer.select(customer.info.subfields.age.as('years')),
pg: {
text : 'SELECT ("customer"."info")."age" AS "years" FROM "customer"',
string: 'SELECT ("customer"."info")."age" AS "years" FROM "customer"'
},
params: []
});
Harness.test({
query: customer.select(customer.id).where(customer.info.subfields.salary.equals(10)),
pg: {
text : 'SELECT "customer"."id" FROM "customer" WHERE (("customer"."info")."salary" = $1)',
string: 'SELECT "customer"."id" FROM "customer" WHERE (("customer"."info")."salary" = 10)'
},
params: [10]
});
Harness.test({
query: customer.select(customer.info.subfields.name.distinct()),
pg: {
text : 'SELECT DISTINCT(("customer"."info")."name") FROM "customer"',
string: 'SELECT DISTINCT(("customer"."info")."name") FROM "customer"'
},
params: []
});