@fxjs/db-driver
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -209,4 +209,7 @@ /// <reference types="fib-pool" /> | ||
rollback() { } | ||
/** | ||
* @override | ||
*/ | ||
execute(sql) { return; } | ||
} | ||
exports.SQLDriver = SQLDriver; |
@@ -54,3 +54,13 @@ /// <reference types="fib-pool" /> | ||
rollback() { return this.connection.rollback(); } | ||
getConnection() { return db.openPSQL(this.uri); } | ||
getConnection() { | ||
var _a, _b; | ||
const conn = db.openPSQL(this.uri); | ||
let searchPath = ((_a = this.config.query) === null || _a === void 0 ? void 0 : _a.search_path) || ((_b = this.config.query) === null || _b === void 0 ? void 0 : _b.searchPath) || ''; | ||
if (searchPath) { | ||
searchPath = (0, utils_1.filterPSQLSearchPath)(searchPath); | ||
searchPath && conn.execute(`SET search_path TO ${searchPath}`); | ||
} | ||
; | ||
return conn; | ||
} | ||
dbExists(dbname) { | ||
@@ -57,0 +67,0 @@ return this.execute(`SELECT datname FROM pg_database WHERE datname = '${dbname}'`).length > 0; |
/// <reference types="@fibjs/types" /> | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.detectWindowsCodePoints = exports.logDebugSQL = exports.arraify = exports.mountPoolToDriver = exports.parsePoolConfig = exports.parseConnectionString = exports.ensureSuffix = exports.castQueryStringToBoolean = exports.forceInteger = exports.filterDriverType = exports.driverUUid = void 0; | ||
exports.filterPSQLSearchPath = 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"); | ||
@@ -203,1 +203,7 @@ const util = require("util"); | ||
exports.detectWindowsCodePoints = detectWindowsCodePoints; | ||
function filterPSQLSearchPath(input_sp) { | ||
input_sp = Array.isArray(input_sp) ? input_sp.join(', ') : `${input_sp}`; | ||
const filtered_sp = input_sp === null || input_sp === void 0 ? void 0 : input_sp.replace(/[^a-zA-Z0-9_"$,]/g, ''); | ||
return filtered_sp || ''; | ||
} | ||
exports.filterPSQLSearchPath = filterPSQLSearchPath; |
{ | ||
"name": "@fxjs/db-driver", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "", | ||
@@ -61,3 +61,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "f2420f3142155b3a2946131c521dad005940e7f1" | ||
"gitHead": "2b370856aaa238d014c9a4149819358abf8152ee" | ||
} |
@@ -94,4 +94,7 @@ /// <reference types="@fibjs/types" /> | ||
rollback(): void; | ||
/** | ||
* @override | ||
*/ | ||
execute<T>(sql: string): T; | ||
} | ||
export {}; |
@@ -16,1 +16,2 @@ import { FxDbDriverNS } from './Typo'; | ||
}; | ||
export declare function filterPSQLSearchPath(input_sp?: string | string[]): string; |
59621
1763