Skip to content

Commit 7613d9c

Browse files
committed
Merge pull request brianc#719 from marekventur/master
Add test for using intervals as parameter in prepared statements
2 parents 8c10612 + 4e37b1f commit 7613d9c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/integration/client/prepared-statement-tests.js

+26
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,32 @@ test("simple, unnamed prepared statement", function(){
1717
});
1818
});
1919

20+
test("use interval in prepared statement", function(){
21+
var client = helper.client();
22+
23+
client.query('SELECT interval \'15 days 2 months 3 years 6:12:05\' as interval', assert.success(function(result) {
24+
var interval = result.rows[0].interval;
25+
26+
var query = client.query({
27+
text: 'select cast($1 as interval) as interval',
28+
values: [interval]
29+
});
30+
31+
assert.emits(query, 'row', function(row) {
32+
assert.equal(row.interval.seconds, 5);
33+
assert.equal(row.interval.minutes, 12);
34+
assert.equal(row.interval.hours, 6);
35+
assert.equal(row.interval.days, 15);
36+
assert.equal(row.interval.months, 2);
37+
assert.equal(row.interval.years, 3);
38+
});
39+
40+
assert.emits(query, 'end', function() {
41+
client.end();
42+
});
43+
}));
44+
});
45+
2046
test("named prepared statement", function() {
2147

2248
var client = helper.client();

0 commit comments

Comments
 (0)