forked from brianc/node-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson-tests.js
More file actions
41 lines (36 loc) · 1.19 KB
/
json-tests.js
File metadata and controls
41 lines (36 loc) · 1.19 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
'use strict';
var Harness = require('./support');
var customer = Harness.defineCustomerTable();
var Sql = require('../../lib').setDialect('postgres');
Harness.test({
query: customer.select(customer.metadata.key('age')),
pg: {
text : 'SELECT ("customer"."metadata" -> $1) FROM "customer"',
string: 'SELECT ("customer"."metadata" -> \'age\') FROM "customer"'
},
params: ['age']
});
Harness.test({
query: customer.select(customer.metadata.keyText('age')),
pg: {
text : 'SELECT ("customer"."metadata" ->> $1) FROM "customer"',
string: 'SELECT ("customer"."metadata" ->> \'age\') FROM "customer"'
},
params: ['age']
});
Harness.test({
query: customer.select(customer.metadata.path('{address,city}')),
pg: {
text : 'SELECT ("customer"."metadata" #> $1) FROM "customer"',
string: 'SELECT ("customer"."metadata" #> \'{address,city}\') FROM "customer"'
},
params: ['{address,city}']
});
Harness.test({
query: customer.select(customer.metadata.pathText('{address,city}')),
pg: {
text : 'SELECT ("customer"."metadata" #>> $1) FROM "customer"',
string: 'SELECT ("customer"."metadata" #>> \'{address,city}\') FROM "customer"'
},
params: ['{address,city}']
});