Skip to content

Commit 3dee76d

Browse files
authored
Clarify that interval inputs must follow pg format (#41)
* docs: add note about trusted input format * Add test for empty interval
1 parent ce74466 commit 3dee76d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Type: `string`
4141

4242
A Postgres interval string.
4343

44+
This package is focused on parsing Postgres outputs. It optimizes for performance by assuming that inputs follow the default interval format. It does not perform any validation on the input. If any interval field is not found, its value will be set to `0` in the returned `interval`.
45+
4446
#### `interval.toPostgres()` -> `string`
4547

4648
Returns an interval string. This allows the interval object to be passed into prepared statements.

test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ test(function (t) {
3939
t.end()
4040
})
4141

42+
t.test('empty', function (t) {
43+
const result = interval('')
44+
t.equal(result.years, 0)
45+
t.equal(result.months, 0)
46+
t.equal(result.days, 0)
47+
t.equal(result.hours, 0)
48+
t.equal(result.seconds, 0)
49+
t.equal(result.milliseconds, 0)
50+
51+
t.end()
52+
})
53+
4254
t.end()
4355
})
4456

0 commit comments

Comments
 (0)