@sqb/postgres
Advanced tools
Comparing version 4.18.0 to 4.19.0
@@ -6,20 +6,19 @@ "use strict"; | ||
const postgrejs_1 = require("postgrejs"); | ||
const datatype_map_js_1 = require("./datatype-map.js"); | ||
const SqbDataTypToOIDMap = { | ||
[connect_1.DataType.BOOL]: postgrejs_1.DataTypeOIDs.bool, | ||
[connect_1.DataType.CHAR]: postgrejs_1.DataTypeOIDs.char, | ||
[connect_1.DataType.VARCHAR]: postgrejs_1.DataTypeOIDs.varchar, | ||
[connect_1.DataType.SMALLINT]: postgrejs_1.DataTypeOIDs.int2, | ||
[connect_1.DataType.INTEGER]: postgrejs_1.DataTypeOIDs.int4, | ||
[connect_1.DataType.BIGINT]: postgrejs_1.DataTypeOIDs.int8, | ||
[connect_1.DataType.FLOAT]: postgrejs_1.DataTypeOIDs.float4, | ||
[connect_1.DataType.DOUBLE]: postgrejs_1.DataTypeOIDs.float8, | ||
[connect_1.DataType.NUMBER]: postgrejs_1.DataTypeOIDs.float8, | ||
[connect_1.DataType.DATE]: postgrejs_1.DataTypeOIDs.date, | ||
[connect_1.DataType.TIMESTAMP]: postgrejs_1.DataTypeOIDs.timestamp, | ||
[connect_1.DataType.TIMESTAMPTZ]: postgrejs_1.DataTypeOIDs.timestamptz, | ||
[connect_1.DataType.TIME]: postgrejs_1.DataTypeOIDs.time, | ||
[connect_1.DataType.BINARY]: postgrejs_1.DataTypeOIDs.bytea, | ||
[connect_1.DataType.TEXT]: postgrejs_1.DataTypeOIDs.text, | ||
[connect_1.DataType.GUID]: postgrejs_1.DataTypeOIDs.uuid, | ||
[connect_1.DataType.BOOL]: [postgrejs_1.DataTypeOIDs.bool, postgrejs_1.DataTypeOIDs._bool], | ||
[connect_1.DataType.CHAR]: [postgrejs_1.DataTypeOIDs.char, postgrejs_1.DataTypeOIDs._char], | ||
[connect_1.DataType.VARCHAR]: [postgrejs_1.DataTypeOIDs.varchar, postgrejs_1.DataTypeOIDs._varchar], | ||
[connect_1.DataType.SMALLINT]: [postgrejs_1.DataTypeOIDs.int2, postgrejs_1.DataTypeOIDs._int2], | ||
[connect_1.DataType.INTEGER]: [postgrejs_1.DataTypeOIDs.int4, postgrejs_1.DataTypeOIDs._int4], | ||
[connect_1.DataType.BIGINT]: [postgrejs_1.DataTypeOIDs.int8, postgrejs_1.DataTypeOIDs._int8], | ||
[connect_1.DataType.FLOAT]: [postgrejs_1.DataTypeOIDs.float4, postgrejs_1.DataTypeOIDs._float4], | ||
[connect_1.DataType.DOUBLE]: [postgrejs_1.DataTypeOIDs.float8, postgrejs_1.DataTypeOIDs._float8], | ||
[connect_1.DataType.NUMBER]: [postgrejs_1.DataTypeOIDs.float8, postgrejs_1.DataTypeOIDs._float8], | ||
[connect_1.DataType.DATE]: [postgrejs_1.DataTypeOIDs.date, postgrejs_1.DataTypeOIDs._date], | ||
[connect_1.DataType.TIMESTAMP]: [postgrejs_1.DataTypeOIDs.timestamp, postgrejs_1.DataTypeOIDs._timestamp], | ||
[connect_1.DataType.TIMESTAMPTZ]: [postgrejs_1.DataTypeOIDs.timestamptz, postgrejs_1.DataTypeOIDs._timestamptz], | ||
[connect_1.DataType.TIME]: [postgrejs_1.DataTypeOIDs.time, postgrejs_1.DataTypeOIDs._time], | ||
[connect_1.DataType.BINARY]: [postgrejs_1.DataTypeOIDs.bytea, postgrejs_1.DataTypeOIDs._bytea], | ||
[connect_1.DataType.TEXT]: [postgrejs_1.DataTypeOIDs.text, postgrejs_1.DataTypeOIDs._text], | ||
[connect_1.DataType.GUID]: [postgrejs_1.DataTypeOIDs.uuid, postgrejs_1.DataTypeOIDs._uuid], | ||
}; | ||
@@ -105,3 +104,3 @@ class PgConnection { | ||
if (v != null && paramOpts && paramOpts.dataType) { | ||
const oid = (0, datatype_map_js_1.dataTypeToOID)(paramOpts.dataType, paramOpts.isArray); | ||
const oid = SqbDataTypToOIDMap[paramOpts.dataType]?.[paramOpts.isArray ? 1 : 0]; | ||
if (oid) | ||
@@ -121,3 +120,3 @@ return new postgrejs_1.BindParam(oid, v); | ||
const items = query.fetchAsString.reduce((a, v) => { | ||
const oid = SqbDataTypToOIDMap[v]; | ||
const oid = SqbDataTypToOIDMap[v][0]; | ||
if (oid) | ||
@@ -124,0 +123,0 @@ a.push(oid); |
import { DataType } from '@sqb/connect'; | ||
import { BindParam, DataTypeOIDs } from 'postgrejs'; | ||
import { dataTypeToOID } from './datatype-map.js'; | ||
const SqbDataTypToOIDMap = { | ||
[DataType.BOOL]: DataTypeOIDs.bool, | ||
[DataType.CHAR]: DataTypeOIDs.char, | ||
[DataType.VARCHAR]: DataTypeOIDs.varchar, | ||
[DataType.SMALLINT]: DataTypeOIDs.int2, | ||
[DataType.INTEGER]: DataTypeOIDs.int4, | ||
[DataType.BIGINT]: DataTypeOIDs.int8, | ||
[DataType.FLOAT]: DataTypeOIDs.float4, | ||
[DataType.DOUBLE]: DataTypeOIDs.float8, | ||
[DataType.NUMBER]: DataTypeOIDs.float8, | ||
[DataType.DATE]: DataTypeOIDs.date, | ||
[DataType.TIMESTAMP]: DataTypeOIDs.timestamp, | ||
[DataType.TIMESTAMPTZ]: DataTypeOIDs.timestamptz, | ||
[DataType.TIME]: DataTypeOIDs.time, | ||
[DataType.BINARY]: DataTypeOIDs.bytea, | ||
[DataType.TEXT]: DataTypeOIDs.text, | ||
[DataType.GUID]: DataTypeOIDs.uuid, | ||
[DataType.BOOL]: [DataTypeOIDs.bool, DataTypeOIDs._bool], | ||
[DataType.CHAR]: [DataTypeOIDs.char, DataTypeOIDs._char], | ||
[DataType.VARCHAR]: [DataTypeOIDs.varchar, DataTypeOIDs._varchar], | ||
[DataType.SMALLINT]: [DataTypeOIDs.int2, DataTypeOIDs._int2], | ||
[DataType.INTEGER]: [DataTypeOIDs.int4, DataTypeOIDs._int4], | ||
[DataType.BIGINT]: [DataTypeOIDs.int8, DataTypeOIDs._int8], | ||
[DataType.FLOAT]: [DataTypeOIDs.float4, DataTypeOIDs._float4], | ||
[DataType.DOUBLE]: [DataTypeOIDs.float8, DataTypeOIDs._float8], | ||
[DataType.NUMBER]: [DataTypeOIDs.float8, DataTypeOIDs._float8], | ||
[DataType.DATE]: [DataTypeOIDs.date, DataTypeOIDs._date], | ||
[DataType.TIMESTAMP]: [DataTypeOIDs.timestamp, DataTypeOIDs._timestamp], | ||
[DataType.TIMESTAMPTZ]: [DataTypeOIDs.timestamptz, DataTypeOIDs._timestamptz], | ||
[DataType.TIME]: [DataTypeOIDs.time, DataTypeOIDs._time], | ||
[DataType.BINARY]: [DataTypeOIDs.bytea, DataTypeOIDs._bytea], | ||
[DataType.TEXT]: [DataTypeOIDs.text, DataTypeOIDs._text], | ||
[DataType.GUID]: [DataTypeOIDs.uuid, DataTypeOIDs._uuid], | ||
}; | ||
@@ -101,3 +100,3 @@ export class PgConnection { | ||
if (v != null && paramOpts && paramOpts.dataType) { | ||
const oid = dataTypeToOID(paramOpts.dataType, paramOpts.isArray); | ||
const oid = SqbDataTypToOIDMap[paramOpts.dataType]?.[paramOpts.isArray ? 1 : 0]; | ||
if (oid) | ||
@@ -117,3 +116,3 @@ return new BindParam(oid, v); | ||
const items = query.fetchAsString.reduce((a, v) => { | ||
const oid = SqbDataTypToOIDMap[v]; | ||
const oid = SqbDataTypToOIDMap[v][0]; | ||
if (oid) | ||
@@ -120,0 +119,0 @@ a.push(oid); |
{ | ||
"name": "@sqb/postgres", | ||
"description": "SQB serialization extension for PostgreSQL database", | ||
"version": "4.18.0", | ||
"version": "4.19.0", | ||
"author": "Panates", | ||
@@ -12,5 +12,5 @@ "license": "Apache-2.0", | ||
"peerDependencies": { | ||
"@sqb/builder": "^4.18.0", | ||
"@sqb/connect": "^4.18.0", | ||
"@sqb/postgres-dialect": "^4.18.0", | ||
"@sqb/builder": "^4.19.0", | ||
"@sqb/connect": "^4.19.0", | ||
"@sqb/postgres-dialect": "^4.19.0", | ||
"postgrejs": ">=2.15.1 <3.0.0" | ||
@@ -17,0 +17,0 @@ }, |
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
31364
15
441