This commit is contained in:
Tutur33
2023-11-24 22:35:41 +01:00
parent 3c0b507a93
commit 7644b2a0f7
45165 changed files with 4803356 additions and 3 deletions
+43
View File
@@ -0,0 +1,43 @@
"use strict";
/* eslint-disable @typescript-eslint/no-shadow */
/*
* knex-dynamic-connection
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.acquireRawConnection = void 0;
/**
* Copy of `acquireRawConnection` from knex codebase, but instead relies
* on `getRuntimeConnectionSettings` vs `connectionSettings`
*/
/* eslint no-shadow: "off" */
function acquireRawConnection() {
const client = this;
const connection = new client.driver.Client(client.getRuntimeConnectionSettings());
connection.on('error', (err) => {
connection.__knex__disposed = err;
});
connection.on('end', (err) => {
connection.__knex__disposed = err || 'Connection ended unexpectedly';
});
return connection
.connect()
.then(() => {
if (!client.version) {
return client.checkVersion(connection).then(function (version) {
client.version = version;
return connection;
});
}
return connection;
})
.then(function setSearchPath(connection) {
client.setSchemaSearchPath(connection);
return connection;
});
}
exports.acquireRawConnection = acquireRawConnection;