@@ -5,7 +5,7 @@ var assert = require('assert')
5
5
const pool = new helper . pg . Pool ( {
6
6
maxResultSize : 100 , // Very small size limit (100 bytes)
7
7
// Keep other connection parameters from helper
8
- ...helper . args
8
+ ...helper . args ,
9
9
} )
10
10
11
11
// Flag to track if we've seen the first type of error message
@@ -14,24 +14,27 @@ let sizeExceededErrorSeen = false
14
14
pool . connect (
15
15
assert . success ( function ( client ) {
16
16
// First create a temp table
17
- client . query ( 'CREATE TEMP TABLE large_result_test(id SERIAL, data TEXT)' , assert . success ( function ( ) {
18
- // Insert data that will exceed the size limit when selected
19
- const insertPromises = [ ]
20
- for ( let i = 0 ; i < 20 ; i ++ ) {
21
- // Each row will have 50 bytes of data
22
- const data = 'x' . repeat ( 50 )
23
- insertPromises . push (
24
- client . query ( 'INSERT INTO large_result_test( data) VALUES($1)' , [ data ] )
25
- )
26
- }
17
+ client . query (
18
+ 'CREATE TEMP TABLE large_result_test(id SERIAL, data TEXT)' ,
19
+ assert . success ( function ( ) {
20
+ // Insert data that will exceed the size limit when selected
21
+ const insertPromises = [ ]
22
+ for ( let i = 0 ; i < 20 ; i ++ ) {
23
+ // Each row will have 50 bytes of data
24
+ const data = 'x' . repeat ( 50 )
25
+ insertPromises . push ( client . query ( 'INSERT INTO large_result_test(data) VALUES($1)' , [ data ] ) )
26
+ }
27
27
28
- // After inserting all rows, attempt to select them all
29
- Promise . all ( insertPromises )
30
- . then ( function ( ) {
28
+ // After inserting all rows, attempt to select them all
29
+ Promise . all ( insertPromises ) . then ( function ( ) {
31
30
client . on ( 'error' , ( err ) => {
32
31
// If we see the first error type, mark it
33
32
if ( err . message === 'Query result size exceeded the configured limit' ) {
34
- assert . equal ( err . code , 'RESULT_SIZE_EXCEEDED' , 'Size exceeded error should have RESULT_SIZE_EXCEEDED code' )
33
+ assert . equal (
34
+ err . code ,
35
+ 'RESULT_SIZE_EXCEEDED' ,
36
+ 'Size exceeded error should have RESULT_SIZE_EXCEEDED code'
37
+ )
35
38
sizeExceededErrorSeen = true
36
39
}
37
40
@@ -42,14 +45,16 @@ pool.connect(
42
45
} )
43
46
44
47
// This query should fail due to exceeding size limit
45
- client . query ( 'SELECT * FROM large_result_test' )
48
+ client
49
+ . query ( 'SELECT * FROM large_result_test' )
46
50
. then ( function ( _result ) {
47
51
throw new Error ( 'Query should have failed due to size limit' )
48
52
} )
49
53
. catch ( function ( err ) {
50
54
assert . equal ( err . code , 'RESULT_SIZE_EXCEEDED' , 'Query error should have RESULT_SIZE_EXCEEDED code' )
51
55
} )
52
56
} )
53
- } ) )
57
+ } )
58
+ )
54
59
} )
55
60
)
0 commit comments