-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathhstore-tests.js
More file actions
27 lines (24 loc) · 773 Bytes
/
hstore-tests.js
File metadata and controls
27 lines (24 loc) · 773 Bytes
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
'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.update({
metadata: customer.metadata.concat(sql.functions.HSTORE('age', 20))
}),
pg: {
text : 'UPDATE "customer" SET "metadata" = ("customer"."metadata" || HSTORE($1, $2))',
string: 'UPDATE "customer" SET "metadata" = ("customer"."metadata" || HSTORE(\'age\', 20))'
},
params: ['age', 20]
});
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']
});