File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,17 +140,29 @@ function getMaxRows(): number {
140140 return maxRows ?? fallbackMaxRows ;
141141}
142142
143- function escapeNewline ( a : string | number | null ) : string | number | null {
144- if ( typeof a === 'string' ) {
145- return a . replace ( / \n / g, '\\n' ) . replace ( / \r / g, '\\r' ) ;
143+ function serializeCell ( a : any ) : any {
144+ try {
145+ // serialize buffers as hex strings
146+ if ( Buffer . isBuffer ( a ) ) {
147+ return `0x${ a . toString ( 'hex' ) } ` ;
148+ }
149+ // attempt to serialize all remaining "object" values as JSON
150+ if ( typeof a === 'object' ) {
151+ return JSON . stringify ( a ) ;
152+ }
153+ if ( typeof a === 'string' ) {
154+ return a . replace ( / \n / g, '\\n' ) . replace ( / \r / g, '\\r' ) ;
155+ }
156+ return a ;
157+ } catch {
158+ return a ;
146159 }
147- return a ;
148160}
149161
150162function markdownRow ( row : Row ) : string {
151163 const middle = Object . entries ( row )
152164 . map ( ( pair ) => pair [ 1 ] )
153- . map ( escapeNewline )
165+ . map ( serializeCell )
154166 . join ( ' | ' ) ;
155167 return `| ${ middle } |` ;
156168}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export type ExecutionResult = TabularResult[];
1919export type TabularResult = Row [ ] ;
2020
2121// Row represents an arbitrary map of data with marshallable values.
22- export type Row = { [ key : string ] : string | number | null } ;
22+ export type Row = { [ key : string ] : any } ;
2323
2424// Conn is an abstraction over driver-specific connection interfaces.
2525interface Conn {
You can’t perform that action at this time.
0 commit comments