File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use strict'
22
33const defaults = require ( './defaults' )
4- const { deprecate , types } = require ( 'util' )
4+ const nodeUtils = require ( 'util' )
55
6- const { isDate } = types
6+ const { isDate } = require ( 'util/ types' )
77
8- const invalidDateDeprecationNotice = deprecate (
8+ const invalidDateDeprecationNotice = nodeUtils . deprecate (
99 ( ) => { } ,
1010 'Sending an invalid date to Postgres is deprecated and will throw an error in the next major version of pg. Ensure any Date object passed as a query parameter is valid.' ,
1111 'PG_INVALID_DATE'
Original file line number Diff line number Diff line change @@ -89,22 +89,15 @@ test('prepareValues: 1 BC date prepared properly', function () {
8989 helper . resetTimezoneOffset ( )
9090} )
9191
92- test ( 'prepareValues: invalid date emits deprecation warning' , function ( ) {
93- const date = new Date ( undefined )
94-
92+ test ( 'prepareValue: invalid date emits deprecation warning' , function ( ) {
9593 const warningPromise = new Promise ( ( resolve ) => {
96- const onWarning = ( warning ) => {
97- if ( warning . code === 'PG_INVALID_DATE' ) {
98- process . removeListener ( 'warning' , onWarning )
99- resolve ( warning )
100- }
101- }
102- process . on ( 'warning' , onWarning )
94+ process . once ( 'warning' , ( warning ) => {
95+ resolve ( warning )
96+ } )
10397 } )
10498
105- const out = utils . prepareValue ( date )
99+ const out = utils . prepareValue ( new Date ( undefined ) )
106100
107- // still serializes (for backwards compatibility) but warns that this is deprecated
108101 assert . strictEqual ( out , '0NaN-NaN-NaNTNaN:NaN:NaN.NaN+NaN:NaN' )
109102
110103 return warningPromise
You can’t perform that action at this time.
0 commit comments