You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
7.8 KiB
8 lines
7.8 KiB
2 years ago
|
{
|
||
|
"version": 3,
|
||
|
"sources": ["../../../src/dialects/oracle/connection-manager.js"],
|
||
|
"sourcesContent": ["// Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved\n\n'use strict';\n\nconst AbstractConnectionManager = require('../abstract/connection-manager');\nconst SequelizeErrors = require('../../errors');\nconst parserStore = require('../parserStore')('oracle');\nconst { logger } = require('../../utils/logger');\nconst semver = require('semver');\nconst debug = logger.debugContext('connection:oracle');\nconst DataTypes = require('../../data-types').oracle;\nconst { promisify } = require('util');\n/**\n * Oracle Connection Manager\n *\n * Get connections, validate and disconnect them.\n * AbstractConnectionManager pooling use it to handle Oracle specific connections\n * Use github.com/oracle/node-oracledb to connect with Oracle server\n *\n * @private\n */\nexport class OracleConnectionManager extends AbstractConnectionManager {\n constructor(dialect, sequelize) {\n super(dialect, sequelize);\n\n this.sequelize = sequelize;\n this.sequelize.config.port = this.sequelize.config.port || 1521;\n this.lib = this._loadDialectModule('oracledb');\n this.extendLib();\n this.refreshTypeParser(DataTypes);\n }\n\n /**\n * Method for initializing the lib\n *\n */\n extendLib() {\n if (this.sequelize.config && 'dialectOptions' in this.sequelize.config) {\n const dialectOptions = this.sequelize.config.dialectOptions;\n if (dialectOptions && 'maxRows' in dialectOptions) {\n this.lib.maxRows = this.sequelize.config.dialectOptions.maxRows;\n }\n if (dialectOptions && 'fetchAsString' in dialectOptions) {\n this.lib.fetchAsString = this.sequelize.config.dialectOptions.fetchAsString;\n } else {\n this.lib.fetchAsString = [this.lib.CLOB];\n }\n }\n // Retrieve BLOB always as Buffer.\n this.lib.fetchAsBuffer = [this.lib.BLOB];\n }\n\n /**\n * Method for checking the config object passed and generate the full database if not fully passed\n * With dbName, host and port, it generates a string like this : 'host:port/dbname'\n *\n * @param {object} config\n * @returns {Promise<Connection>}\n * @private\n */\n buildConnectString(config) {\n if (!config.host || config.host.length === 0)\n return config.database;\n let connectString = config.host;\n if (config.port && config.port > 0) {\n connectString += `:${config.port}`;\n } else {\n connectString += ':1521';\n }\n if (config.database && config.database.length > 0) {\n connectString += `/${config.database}`;\n }\n return connectString;\n }\n\n // Expose this as a method so that the parsing may be updated when the user has added additional, custom types\n _refreshTypeParser(dataType) {\n parserStore.refresh(dataType);\n }\n\n _clearTypeParser() {\n parserStore.clear();\n }\n\n /**\n * Connect with Oracle database based on config, Handle any errors in connection\n * Set the pool handlers on connection.error\n * Also set proper timezone once connection is connected.\n *\n * @param {object} config\n * @returns {Promise<Connection>}\n * @private\n */\n async connect(config) {\n const connectionConfig = {\n user: config.username,\n password: config.password,\n externalAuth: config.externalAuth,\n stmtCacheSize: 0,\n connectString: this.buildConnectString(config),\n ...config.dialectOptions\n };\n\n try {\n const connection = await this.lib.getConnection(connectionConfig);\n // Setting the sequelize database version to Oracle DB server version to remove the roundtrip for DB version query\n this.sequelize.options.databaseVersion = semver.coerce(connection.oracleServerVersionString).version;\n\n debug('connection acquired');\n connection.on('error', error => {\n switch (error.code) {\n case 'ESOCKET':\n case 'ECONNRESET':\n case 'EPIPE':\n case 'PROTOCOL_CONNECTION_LOST':\n this.pool.destroy(connection);\n }\n });\n\n return connection;\n } catch (err) {\n
|
||
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAIA,MAAM,4BAA4B,QAAQ;AAC1C,MAAM,kBAAkB,QAAQ;AAChC,MAAM,cAAc,QAAQ,kBAAkB;AAC9C,MAAM,EAAE,WAAW,QAAQ;AAC3B,MAAM,SAAS,QAAQ;AACvB,MAAM,QAAQ,OAAO,aAAa;AAClC,MAAM,YAAY,QAAQ,oBAAoB;AAC9C,MAAM,EAAE,cAAc,QAAQ;AAUvB,sCAAsC,0BAA0B;AAAA,EACrE,YAAY,SAAS,WAAW;AAC9B,UAAM,SAAS;AAEf,SAAK,YAAY;AACjB,SAAK,UAAU,OAAO,OAAO,KAAK,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