File tree Expand file tree Collapse file tree 4 files changed +20
-11
lines changed Expand file tree Collapse file tree 4 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 11import { parseConnectionUri } from "../utils/utils.ts" ;
22import { ConnectionParamsError } from "../client/error.ts" ;
33import { fromFileUrl , isAbsolute } from "../deps.ts" ;
4- import { OidKey } from "../query/oid.ts" ;
4+ import { OidType } from "../query/oid.ts" ;
55
66/**
77 * The connection string must match the following URI structure. All parameters but database and user are optional
@@ -92,9 +92,17 @@ export interface TLSOptions {
9292 caCertificates : string [ ] ;
9393}
9494
95+ /**
96+ * The strategy to use when decoding results data
97+ */
9598export type DecodeStrategy = "string" | "auto" ;
99+ /**
100+ * A dictionary of functions used to decode (parse) column field values from string to a custom type. These functions will
101+ * take precedence over the {@linkcode DecodeStrategy}. Each key in the dictionary is the column OID type number or Oid type name,
102+ * and the value is the decoder function.
103+ */
96104export type Decoders = {
97- [ key in number | OidKey ] ?: DecoderFunction ;
105+ [ key in number | OidType ] ?: DecoderFunction ;
98106} ;
99107
100108/**
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export { Oid, OidTypes } from "./query/oid.ts";
1010// TODO
1111// Remove the following reexports after https://doc.deno.land
1212// supports two level depth exports
13- export type { OidKey , OidType } from "./query/oid.ts" ;
13+ export type { OidType , OidValue } from "./query/oid.ts" ;
1414export type {
1515 ClientOptions ,
1616 ConnectionOptions ,
Original file line number Diff line number Diff line change 1- import { Oid , OidType , OidTypes } from "./oid.ts" ;
1+ import { Oid , OidTypes , OidValue } from "./oid.ts" ;
22import { bold , yellow } from "../deps.ts" ;
33import {
44 decodeBigint ,
@@ -218,7 +218,7 @@ export function decode(
218218 if ( controls ?. decoders ) {
219219 // check if there is a custom decoder by oid (number) or by type name (string)
220220 const decoderFunc = controls . decoders ?. [ column . typeOid ] ||
221- controls . decoders ?. [ OidTypes [ column . typeOid as OidType ] ] ;
221+ controls . decoders ?. [ OidTypes [ column . typeOid as OidValue ] ] ;
222222
223223 if ( decoderFunc ) {
224224 return decoderFunc ( strValue , column . typeOid ) ;
Original file line number Diff line number Diff line change 1- export type OidKey = keyof typeof Oid ;
2- export type OidType = ( typeof Oid ) [ OidKey ] ;
1+ /** A Postgres Object identifiers (OIDs) type name. */
2+ export type OidType = keyof typeof Oid ;
3+ /** A Postgres Object identifiers (OIDs) numeric value. */
4+ export type OidValue = ( typeof Oid ) [ OidType ] ;
35
46/**
5- * Oid is a map of OidKey to OidType .
7+ * A map of OidType to OidValue .
68 */
79export const Oid = {
810 bool : 16 ,
@@ -175,11 +177,10 @@ export const Oid = {
175177} as const ;
176178
177179/**
178- * OidTypes is a map of OidType to OidKey.
179- * Used to decode values and avoid search iteration
180+ * A map of OidValue to OidType. Used to decode values and avoid search iteration.
180181 */
181182export const OidTypes : {
182- [ key in OidType ] : OidKey ;
183+ [ key in OidValue ] : OidType ;
183184} = {
184185 16 : "bool" ,
185186 17 : "bytea" ,
You can’t perform that action at this time.
0 commit comments