File tree Expand file tree Collapse file tree 5 files changed +21
-12
lines changed Expand file tree Collapse file tree 5 files changed +21
-12
lines changed Original file line number Diff line number Diff line change 1
1
import { parseConnectionUri } from "../utils/utils.ts" ;
2
2
import { ConnectionParamsError } from "../client/error.ts" ;
3
3
import { fromFileUrl , isAbsolute } from "../deps.ts" ;
4
- import { OidKey } from "../query/oid.ts" ;
4
+ import { OidType } from "../query/oid.ts" ;
5
5
6
6
/**
7
7
* The connection string must match the following URI structure. All parameters but database and user are optional
@@ -92,9 +92,17 @@ export interface TLSOptions {
92
92
caCertificates : string [ ] ;
93
93
}
94
94
95
+ /**
96
+ * The strategy to use when decoding results data
97
+ */
95
98
export 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
+ */
96
104
export type Decoders = {
97
- [ key in number | OidKey ] ?: DecoderFunction ;
105
+ [ key in number | OidType ] ?: DecoderFunction ;
98
106
} ;
99
107
100
108
/**
Original file line number Diff line number Diff line change 1
1
{
2
2
"lock" : false ,
3
3
"name" : " @bartlomieju/postgres" ,
4
- "version" : " 0.18.0 " ,
4
+ "version" : " 0.18.1 " ,
5
5
"exports" : " ./mod.ts"
6
6
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export { Oid, OidTypes } from "./query/oid.ts";
10
10
// TODO
11
11
// Remove the following reexports after https://doc.deno.land
12
12
// supports two level depth exports
13
- export type { OidKey , OidType } from "./query/oid.ts" ;
13
+ export type { OidType , OidValue } from "./query/oid.ts" ;
14
14
export type {
15
15
ClientOptions ,
16
16
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" ;
2
2
import { bold , yellow } from "../deps.ts" ;
3
3
import {
4
4
decodeBigint ,
@@ -218,7 +218,7 @@ export function decode(
218
218
if ( controls ?. decoders ) {
219
219
// check if there is a custom decoder by oid (number) or by type name (string)
220
220
const decoderFunc = controls . decoders ?. [ column . typeOid ] ||
221
- controls . decoders ?. [ OidTypes [ column . typeOid as OidType ] ] ;
221
+ controls . decoders ?. [ OidTypes [ column . typeOid as OidValue ] ] ;
222
222
223
223
if ( decoderFunc ) {
224
224
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 ] ;
3
5
4
6
/**
5
- * Oid is a map of OidKey to OidType .
7
+ * A map of OidType to OidValue .
6
8
*/
7
9
export const Oid = {
8
10
bool : 16 ,
@@ -175,11 +177,10 @@ export const Oid = {
175
177
} as const ;
176
178
177
179
/**
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.
180
181
*/
181
182
export const OidTypes : {
182
- [ key in OidType ] : OidKey ;
183
+ [ key in OidValue ] : OidType ;
183
184
} = {
184
185
16 : "bool" ,
185
186
17 : "bytea" ,
You can’t perform that action at this time.
0 commit comments