MCPcopy Index your code
hub / github.com/brianc/node-postgres / parse

Function parse

packages/pg-protocol/src/serializer.ts:72–100  ·  view source on GitHub ↗
(query: ParseOpts)

Source from the content-addressed store, hash-verified

70const emptyArray: any[] = []
71
72const parse = (query: ParseOpts): Buffer => {
73 // expect something like this:
74 // { name: 'queryName',
75 // text: 'select * from blah',
76 // types: ['int8', 'bool'] }
77
78 // normalize missing query names to allow for null
79 const name = query.name || ''
80 if (name.length > 63) {
81 console.error('Warning! Postgres only supports 63 characters for query names.')
82 console.error('You supplied %s (%s)', name, name.length)
83 console.error('This can cause conflicts and silent errors executing queries')
84 }
85
86 const types = query.types || emptyArray
87
88 const len = types.length
89
90 const buffer = writer
91 .addCString(name) // name of query
92 .addCString(query.text) // actual query text
93 .addInt16(len)
94
95 for (let i = 0; i < len; i++) {
96 buffer.addInt32(types[i])
97 }
98
99 return writer.flush(code.parse)
100}
101
102type ValueMapper = (param: any, index: number) => any
103

Callers

nothing calls this directly

Calls 4

addInt16Method · 0.45
addCStringMethod · 0.45
addInt32Method · 0.45
flushMethod · 0.45

Tested by

no test coverage detected