postgresql-client
Advanced tools
Comparing version 2.8.1 to 2.9.0
@@ -0,1 +1,10 @@ | ||
# v2.9.0 | ||
[2023-10-03] | ||
### Changes | ||
* Added int2Vector data type with binary protocol ([`55bd87e`](https://github.com/panates/postgresql-client/commit/55bd87e38a2ed1787957c1066ba51857d6c97c5d)) | ||
* Support int2 and oid vector types ([`ce27006`](https://github.com/panates/postgresql-client/commit/ce27006bb7441d004fd251bd6af29c4e99836b01)) | ||
* Add OID for tid array ([`d99e3ee`](https://github.com/panates/postgresql-client/commit/d99e3ee1e7fc768931553240adb556f003428ebd)) | ||
# v2.8.1 | ||
@@ -2,0 +11,0 @@ [2023-10-03] |
@@ -103,2 +103,3 @@ "use strict"; | ||
_text: 1009, | ||
_tid: 1010, | ||
_xid: 1011, | ||
@@ -219,2 +220,3 @@ _cid: 1012, | ||
[exports.DataTypeOIDs._text]: "_text", | ||
[exports.DataTypeOIDs._tid]: "_tid", | ||
[exports.DataTypeOIDs._xid]: "_xid", | ||
@@ -221,0 +223,0 @@ [exports.DataTypeOIDs._cid]: "_cid", |
@@ -14,2 +14,3 @@ "use strict"; | ||
const int2_type_js_1 = require("./data-types/int2-type.js"); | ||
const int2_vector_type_js_1 = require("./data-types/int2-vector-type.js"); | ||
const int4_type_js_1 = require("./data-types/int4-type.js"); | ||
@@ -69,3 +70,3 @@ const int8_type_js_1 = require("./data-types/int8-type.js"); | ||
exports.GlobalTypeMap = new DataTypeMap(); | ||
exports.GlobalTypeMap.register([oid_type_js_1.OidType, oid_type_js_1.ArrayOidType]); | ||
exports.GlobalTypeMap.register([oid_type_js_1.OidType, oid_type_js_1.VectorOidType, oid_type_js_1.ArrayOidType]); | ||
exports.GlobalTypeMap.register([jsonb_type_js_1.JsonbType, jsonb_type_js_1.ArrayJsonbType]); | ||
@@ -85,2 +86,3 @@ exports.GlobalTypeMap.register([json_type_js_1.JsonType, json_type_js_1.ArrayJsonType]); | ||
exports.GlobalTypeMap.register([box_type_js_1.BoxType, box_type_js_1.ArrayBoxType]); | ||
exports.GlobalTypeMap.register([int2_vector_type_js_1.Int2VectorType, int2_vector_type_js_1.ArrayInt2VectorType]); | ||
exports.GlobalTypeMap.register({ ...varchar_type_js_1.VarcharType, name: "bpchar", oid: constants_js_1.DataTypeOIDs.bpchar }); | ||
@@ -87,0 +89,0 @@ exports.GlobalTypeMap.register({ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ArrayOidType = exports.OidType = void 0; | ||
exports.VectorOidType = exports.ArrayOidType = exports.OidType = void 0; | ||
const constants_js_1 = require("../constants.js"); | ||
@@ -27,1 +27,7 @@ const fast_parseint_js_1 = require("../util/fast-parseint.js"); | ||
}; | ||
exports.VectorOidType = { | ||
...exports.OidType, | ||
name: "_oidvector", | ||
oid: constants_js_1.DataTypeOIDs.oidvector, | ||
elementsOID: constants_js_1.DataTypeOIDs.oid, | ||
}; |
@@ -119,3 +119,3 @@ "use strict"; | ||
v = Array.isArray(v) ? v : [v]; | ||
(0, encode_binaryarray_js_1.encodeBinaryArray)(io, v, dt.elementsOID, queryOptions, dt.encodeBinary); | ||
(0, encode_binaryarray_js_1.encodeBinaryArray)(io, v, dt.elementsOID, queryOptions, dt.encodeBinary, dt.encodeCalculateDim); | ||
} | ||
@@ -122,0 +122,0 @@ else { |
@@ -5,3 +5,3 @@ "use strict"; | ||
const buffer_reader_js_1 = require("../protocol/buffer-reader.js"); | ||
function decodeBinaryArray(buf, decoder, options) { | ||
function decodeBinaryArray(buf, decoder, options = {}) { | ||
if (!buf.length) | ||
@@ -12,3 +12,3 @@ return null; | ||
io.readInt32BE(); // hasNulls | ||
io.readInt32BE(); // element oid | ||
const elementOID = io.readInt32BE(); // element oid | ||
if (ndims === 0) | ||
@@ -28,4 +28,6 @@ return []; | ||
target[i] = null; | ||
else | ||
target[i] = decoder(io.readBuffer(len), options); | ||
else { | ||
const b = io.readBuffer(len); | ||
target[i] = decoder(b, { ...options, elementOID }); | ||
} | ||
} | ||
@@ -32,0 +34,0 @@ return target; |
@@ -6,5 +6,6 @@ "use strict"; | ||
const array_calculatedim_js_1 = require("./array-calculatedim.js"); | ||
function encodeBinaryArray(io, value, itemOid, options, encode) { | ||
function encodeBinaryArray(io, value, itemOid, options, encode, encodeCalculateDimFn) { | ||
encodeCalculateDimFn = encodeCalculateDimFn || array_calculatedim_js_1.arrayCalculateDim; | ||
itemOid = itemOid || constants_js_1.DataTypeOIDs.varchar; | ||
const dim = (0, array_calculatedim_js_1.arrayCalculateDim)(value); | ||
const dim = encodeCalculateDimFn(value); | ||
const ndims = dim.length; | ||
@@ -17,3 +18,3 @@ const zeroOffset = io.offset; | ||
io.writeInt32BE(dim[d]); // Number of items in dimension | ||
io.writeInt32BE(1); // LBound always 1. | ||
io.writeInt32BE(0); // LBound always 0. | ||
} | ||
@@ -20,0 +21,0 @@ let hasNull = false; |
@@ -100,2 +100,3 @@ import { Protocol } from "./protocol/protocol.js"; | ||
_text: 1009, | ||
_tid: 1010, | ||
_xid: 1011, | ||
@@ -216,2 +217,3 @@ _cid: 1012, | ||
[DataTypeOIDs._text]: "_text", | ||
[DataTypeOIDs._tid]: "_tid", | ||
[DataTypeOIDs._xid]: "_xid", | ||
@@ -218,0 +220,0 @@ [DataTypeOIDs._cid]: "_cid", |
@@ -11,2 +11,3 @@ import { DataTypeOIDs } from './constants.js'; | ||
import { ArrayInt2Type, Int2Type } from './data-types/int2-type.js'; | ||
import { ArrayInt2VectorType, Int2VectorType } from './data-types/int2-vector-type.js'; | ||
import { ArrayInt4Type, Int4Type } from './data-types/int4-type.js'; | ||
@@ -18,3 +19,3 @@ import { ArrayInt8Type, Int8Type } from './data-types/int8-type.js'; | ||
import { ArrayNumericType, NumericType } from './data-types/numeric-type.js'; | ||
import { ArrayOidType, OidType } from './data-types/oid-type.js'; | ||
import { ArrayOidType, OidType, VectorOidType } from './data-types/oid-type.js'; | ||
import { ArrayPointType, PointType } from './data-types/point-type.js'; | ||
@@ -66,3 +67,3 @@ import { ArrayTimeType, TimeType } from './data-types/time-type.js'; | ||
export const GlobalTypeMap = new DataTypeMap(); | ||
GlobalTypeMap.register([OidType, ArrayOidType]); | ||
GlobalTypeMap.register([OidType, VectorOidType, ArrayOidType]); | ||
GlobalTypeMap.register([JsonbType, ArrayJsonbType]); | ||
@@ -82,2 +83,3 @@ GlobalTypeMap.register([JsonType, ArrayJsonType]); | ||
GlobalTypeMap.register([BoxType, ArrayBoxType]); | ||
GlobalTypeMap.register([Int2VectorType, ArrayInt2VectorType]); | ||
GlobalTypeMap.register({ ...VarcharType, name: "bpchar", oid: DataTypeOIDs.bpchar }); | ||
@@ -84,0 +86,0 @@ GlobalTypeMap.register({ |
@@ -24,1 +24,7 @@ import { DataTypeNames, DataTypeOIDs } from '../constants.js'; | ||
}; | ||
export const VectorOidType = { | ||
...OidType, | ||
name: "_oidvector", | ||
oid: DataTypeOIDs.oidvector, | ||
elementsOID: DataTypeOIDs.oid, | ||
}; |
@@ -116,3 +116,3 @@ import { DEFAULT_COLUMN_FORMAT } from '../constants.js'; | ||
v = Array.isArray(v) ? v : [v]; | ||
encodeBinaryArray(io, v, dt.elementsOID, queryOptions, dt.encodeBinary); | ||
encodeBinaryArray(io, v, dt.elementsOID, queryOptions, dt.encodeBinary, dt.encodeCalculateDim); | ||
} | ||
@@ -119,0 +119,0 @@ else { |
import { BufferReader } from '../protocol/buffer-reader.js'; | ||
export function decodeBinaryArray(buf, decoder, options) { | ||
export function decodeBinaryArray(buf, decoder, options = {}) { | ||
if (!buf.length) | ||
@@ -8,3 +8,3 @@ return null; | ||
io.readInt32BE(); // hasNulls | ||
io.readInt32BE(); // element oid | ||
const elementOID = io.readInt32BE(); // element oid | ||
if (ndims === 0) | ||
@@ -24,4 +24,6 @@ return []; | ||
target[i] = null; | ||
else | ||
target[i] = decoder(io.readBuffer(len), options); | ||
else { | ||
const b = io.readBuffer(len); | ||
target[i] = decoder(b, { ...options, elementOID }); | ||
} | ||
} | ||
@@ -28,0 +30,0 @@ return target; |
import { DataTypeOIDs } from '../constants.js'; | ||
import { arrayCalculateDim } from './array-calculatedim.js'; | ||
export function encodeBinaryArray(io, value, itemOid, options, encode) { | ||
export function encodeBinaryArray(io, value, itemOid, options, encode, encodeCalculateDimFn) { | ||
encodeCalculateDimFn = encodeCalculateDimFn || arrayCalculateDim; | ||
itemOid = itemOid || DataTypeOIDs.varchar; | ||
const dim = arrayCalculateDim(value); | ||
const dim = encodeCalculateDimFn(value); | ||
const ndims = dim.length; | ||
@@ -13,3 +14,3 @@ const zeroOffset = io.offset; | ||
io.writeInt32BE(dim[d]); // Number of items in dimension | ||
io.writeInt32BE(1); // LBound always 1. | ||
io.writeInt32BE(0); // LBound always 0. | ||
} | ||
@@ -16,0 +17,0 @@ let hasNull = false; |
{ | ||
"name": "postgresql-client", | ||
"description": "Enterprise level PostgreSQL client for JavaScript", | ||
"version": "2.8.1", | ||
"version": "2.9.0", | ||
"author": "Panates", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -98,2 +98,3 @@ import { Protocol } from "./protocol/protocol.js"; | ||
_text: number; | ||
_tid: number; | ||
_xid: number; | ||
@@ -100,0 +101,0 @@ _cid: number; |
import type { DataType } from '../interfaces/data-type.js'; | ||
export declare const OidType: DataType; | ||
export declare const ArrayOidType: DataType; | ||
export declare const VectorOidType: DataType; |
import type { DecodeBinaryFunction, EncodeBinaryFunction, EncodeTextFunction, OID, ParseTextFunction } from '../types.js'; | ||
import { EncodeCalculateDimFunction } from '../types.js'; | ||
export interface DataType { | ||
@@ -6,2 +7,3 @@ oid: OID; | ||
elementsOID?: OID; | ||
isArray?: boolean; | ||
jsType: string; | ||
@@ -14,2 +16,3 @@ arraySeparator?: string; | ||
encodeText?: EncodeTextFunction; | ||
encodeCalculateDim?: EncodeCalculateDimFunction; | ||
} | ||
@@ -16,0 +19,0 @@ export interface Point { |
@@ -9,4 +9,5 @@ /// <reference types="node" /> | ||
export type Callback = (err?: Error, value?: any) => void; | ||
export type DecodeBinaryFunction = (buf: Buffer, options: DataMappingOptions) => any; | ||
export type DecodeBinaryFunction = (buf: Buffer, options: DataMappingOptions & Record<string, any>) => any; | ||
export type EncodeBinaryFunction = (buf: SmartBuffer, v: any, options: DataMappingOptions) => void; | ||
export type EncodeCalculateDimFunction = (v: any[]) => number[]; | ||
export type ParseTextFunction = (v: any, options: DataMappingOptions) => any; | ||
@@ -13,0 +14,0 @@ export type EncodeTextFunction = (v: any, options: DataMappingOptions) => string; |
/// <reference types="node" /> | ||
import { DataMappingOptions } from '../interfaces/data-mapping-options.js'; | ||
import type { DecodeBinaryFunction, Nullable } from '../types.js'; | ||
export declare function decodeBinaryArray(buf: Buffer, decoder: DecodeBinaryFunction, options: DataMappingOptions): Nullable<any[]>; | ||
export declare function decodeBinaryArray<T = any>(buf: Buffer, decoder: DecodeBinaryFunction, options?: DataMappingOptions): Nullable<T[]>; |
import type { DataMappingOptions } from '../interfaces/data-mapping-options.js'; | ||
import type { SmartBuffer } from '../protocol/smart-buffer.js'; | ||
import type { EncodeBinaryFunction, OID } from '../types.js'; | ||
export declare function encodeBinaryArray(io: SmartBuffer, value: any[], itemOid: OID, options: DataMappingOptions, encode: EncodeBinaryFunction): void; | ||
import { EncodeCalculateDimFunction } from '../types.js'; | ||
export declare function encodeBinaryArray(io: SmartBuffer, value: any[], itemOid: OID, options: DataMappingOptions, encode: EncodeBinaryFunction, encodeCalculateDimFn?: EncodeCalculateDimFunction): void; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
412070
215
10067