(query: ParseOpts)
| 79 | const emptyValueArray: LegalValue[] = [] |
| 80 | |
| 81 | const 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 | |
| 111 | type ValueMapper = (param: unknown, index: number) => LegalValue |
| 112 |
nothing calls this directly
no test coverage detected