@fxjs/db-driver
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -6,2 +6,3 @@ /// <reference types="fib-pool" /> | ||
const utils_1 = require("../utils"); | ||
const win32CpInfo = utils_1.detectWindowsCodePoints(); | ||
class PostgreSQLDriver extends base_class_1.SQLDriver { | ||
@@ -23,3 +24,15 @@ constructor(conn) { | ||
} | ||
open() { return super.open(); } | ||
open() { | ||
if (!win32CpInfo.codepoints) | ||
return super.open(); | ||
const conn = super.open(); | ||
// TODO: support common codepoints -> postgresql-encoding | ||
if (conn.codec && win32CpInfo.codepoints === '936') { | ||
conn.codec = 'GBK'; | ||
} | ||
else if (conn.codec === 'utf8' && win32CpInfo.codepoints !== '65001') { | ||
console.error(`system default code points is '${win32CpInfo.codepoints}', but odbc try to use codec UTF8 with codepoints 65001, refer to https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers to set connection.codec as UTF8`); | ||
} | ||
return conn; | ||
} | ||
close() { | ||
@@ -26,0 +39,0 @@ if (this.connection) |
/// <reference types="@fibjs/types" /> | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logDebugSQL = exports.arraify = exports.mountPoolToDriver = exports.parsePoolConfig = exports.parseConnectionString = exports.ensureSuffix = exports.castQueryStringToBoolean = exports.forceInteger = exports.filterDriverType = exports.driverUUid = void 0; | ||
exports.detectWindowsCodePoints = exports.logDebugSQL = exports.arraify = exports.mountPoolToDriver = exports.parsePoolConfig = exports.parseConnectionString = exports.ensureSuffix = exports.castQueryStringToBoolean = exports.forceInteger = exports.filterDriverType = exports.driverUUid = void 0; | ||
const url = require("url"); | ||
@@ -9,2 +9,4 @@ const util = require("util"); | ||
const uuid = require("uuid"); | ||
const io = require("io"); | ||
const child_process = require("child_process"); | ||
const ParseQSDotKey = require("parse-querystring-dotkey"); | ||
@@ -182,1 +184,21 @@ const FibPool = require("fib-pool"); | ||
; | ||
function detectWindowsCodePoints() { | ||
let codepoints = ''; | ||
const isWindows = process.platform === 'win32'; | ||
if (isWindows) { | ||
try { | ||
const p = child_process.spawn('cmd', "/c chcp".split(' ')); | ||
const stdout = new io.BufferedStream(p.stdout); | ||
const output = stdout.readLines().join(' '); | ||
const matches = output.match(/\d+/g); | ||
codepoints = matches === null || matches === void 0 ? void 0 : matches[0]; | ||
} | ||
catch (error) { | ||
} | ||
} | ||
return { | ||
isWindows, | ||
codepoints | ||
}; | ||
} | ||
exports.detectWindowsCodePoints = detectWindowsCodePoints; |
{ | ||
"name": "@fxjs/db-driver", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "", | ||
@@ -60,3 +60,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "69f661603b0536b59c87bdf74460ac0f32cac3d1" | ||
"gitHead": "aa96b7ba2cd225e462b3192104a2a150b448fda7" | ||
} |
@@ -12,1 +12,5 @@ import { FxDbDriverNS } from './Typo'; | ||
export declare function logDebugSQL(dbtype: string, sql: string, is_sync?: boolean): void; | ||
export declare function detectWindowsCodePoints(): { | ||
isWindows: boolean; | ||
codepoints: string; | ||
}; |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
37309
966
2