MCPcopy Index your code
hub / github.com/electric-sql/pglite / parse

Function parse

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

Source from the content-addressed store, hash-verified

79const emptyValueArray: LegalValue[] = []
80
81const parse = (query: ParseOpts): Uint8Array => {
82 // expect something like this:
83 // { name: 'queryName',
84 // text: 'select * from blah',
85 // types: ['int8', 'bool'] }
86
87 // normalize missing query names to allow for null
88 const name = query.name ?? ''
89 if (name.length > 63) {
90 /* eslint-disable no-console */
91 console.error(
92 'Warning! Postgres only supports 63 characters for query names.',
93 )
94 console.error('You supplied %s (%s)', name, name.length)
95 console.error(
96 'This can cause conflicts and silent errors executing queries',
97 )
98 /* eslint-enable no-console */
99 }
100
101 const buffer = writer
102 .addCString(name) // name of query
103 .addCString(query.text) // actual query text
104 .addInt16(query.types?.length ?? 0)
105
106 query.types?.forEach((type) => buffer.addInt32(type))
107
108 return writer.flush(code.parse)
109}
110
111type ValueMapper = (param: unknown, index: number) => LegalValue
112

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected