b0VIM 8.19?`C:jeremyblalockJeremys-MacBook-Pro-16.local~jeremyblalock/Documents/Projects/FlowZ/Code/sequelize/lib/dialects/postgres/connection-manager.jsutf-8 3210#"! Utp ^ Wig'adZ U!tZL `   :  l 3 , +  _ ^  c     edLQG932 po;>=aYX9~! 'ssl', // see also [http://www.postgresql.org/docs/9.3/static/libpq-ssl.html] // object format: [https://github.com/brianc/node-postgres/blob/ee19e74ffa6309c9c5e8e01746261a8f651661f8/lib/connection.js#L79] // choose the SSL mode with the PGSSLMODE environment variable 'application_name', // see [http://www.postgresql.org/docs/9.3/static/runtime-config-logging.html#GUC-APPLICATION-NAME] _.pick(config.dialectOptions, [ _.merge(connectionConfig, if (config.dialectOptions) { }; getTypeParser: ConnectionManager.prototype.getTypeParser.bind(this) connectionConfig.types = { ]); 'user', 'password', 'host', 'database', 'port' const connectionConfig = _.pick(config, [ config.user = config.username; async connect(config) { } return this.lib.types.getTypeParser(oid, ...args); if (this.oidParserMap.get(oid)) return this.oidParserMap.get(oid); getTypeParser(oid, ...args) { } this.oidParserMap = new Map(); _clearTypeParser() { } }); this.oidParserMap.set(this.nameOidMap[name].arrayOid, arrayParser); if (! this.nameOidMap[name].arrayOid) return; this.oidParserMap.set(this.nameOidMap[name].oid, parser); if (! this.nameOidMap[name]) return; dataType.types.postgres.forEach(name => { // Set parsers for normal data types } return; }); this.oidParserMap.set(arrayOid, arrayParser); this.enumOids.arrayOids.forEach(arrayOid => { }); this.oidParserMap.set(oid, parser); this.enumOids.oids.forEach(oid => { if (dataType.key.toLowerCase() === 'enum') { // Set enum parsers const arrayParser = arrayParserBuilder(parser); const parser = value => dataType.parse(value); // Create parsers for normal or enum data types } return; } this.oidParserMap.set(entry.arrayRangeOid, arrayRangeParser); if (! entry.arrayRangeOid) continue; this.oidParserMap.set(entry.rangeOid, rangeParser); const arrayRangeParser = arrayParserBuilder(rangeParser); const rangeParser = rangeParserBuilder(this.getTypeParser(entry.oid)); if (! entry.rangeOid) continue; const entry = this.nameOidMap[name]; for (const name in this.nameOidMap) { if (dataType.key.toLowerCase() === 'range') { // Set range parsers }; return value => dataType.parse(value, { parser }); const rangeParserBuilder = parser => { }; return value => this.lib.types.arrayParser.create(value, parser).parse(); const arrayParserBuilder = parser => { _refreshTypeParser(dataType) { // Expose this as a method so that the parsing may be updated when the user has added additional, custom types } this.refreshTypeParser(dataTypes.postgres); this._clearTypeParser(); this._clearDynamicOIDs(); this.lib = this.sequelize.config.native ? pgLib.native : pgLib; const pgLib = this._loadDialectModule('pg'); super(dialect, sequelize); sequelize.config.port = sequelize.config.port || 5432; constructor(dialect, sequelize) {class ConnectionManager extends AbstractConnectionManager {const { promiconst pg = require('pg');const moment = require('moment-timezone');const dataTypes = require('../../data-types');const semver = require('semver');const sequelizeErrors = require('../../errors');const debug = logger.debugContext('connection:pg');const { logger } = require('../../utils/logger');const AbstractConnectionManager = require('../abstract/connection-manager');const _ = require('lodash');'use strict';adR ~F,B c _ ] \ 8  module.exports.default = ConnectionManager;module.exports.ConnectionManager = ConnectionManager;module.exports = ConnectionManager;} } this.enumOids = { oids: [], arrayOids: [] }; this.nameOidMap = {}; _clearDynamicOIDs() { } this.refreshTypeParser(dataTypes.postgres); this.enumOids = newEnumOids; this.nameOidMap = newNameOidMap; // Replace all OID mappings. Avoids temporary empty OID mappings. } } if (row.rngtyparray) newNameOidMap[row.typname].arrayRangeOid = row.rngtyparray; newNameOidMap[row.typname].rangeOid = row.rngtypid; if (row.rngtypid) { // Mapping ranges(of base types) and their arrays if (row.typarray) newNameOidMap[row.typname].arrayOid = row.typarray; newNameOidMap[row.typname] = { oid: row.oid };adM^x=n>:9 | , % n B  [ Z  Z '  S I  i>wsr[843uR$}vuT4 9^M 'ssl', // see also [http://www.postgresql.org/docs/9.3/static/libpq-ssl.html] // object format: [https://github.com/brianc/node-postgres/blob/ee19e74ffa6309c9c5e8e01746261a8f651661f8/lib/connection.js#L79] // choose the SSL mode with the PGSSLMODE environment variable 'application_name', // see [http://www.postgresql.org/docs/9.3/static/runtime-config-logging.html#GUC-APPLICATION-NAME] _.pick(config.dialectOptions, [ _.merge(connectionConfig, if (config.dialectOptions) { }; getTypeParser: ConnectionManager.prototype.getTypeParser.bind(this) connectionConfig.types = { ]); 'user', 'password', 'host', 'database', 'port' const connectionConfig = _.pick(config, [ config.user = config.username; async connect(config) { } return this.lib.types.getTypeParser(oid, ...args); if (this.oidParserMap.get(oid)) return this.oidParserMap.get(oid); getTypeParser(oid, ...args) { } this.oidParserMap = new Map(); _clearTypeParser() { } }); this.oidParserMap.set(this.nameOidMap[name].arrayOid, arrayParser); if (! this.nameOidMap[name].arrayOid) return; this.oidParserMap.set(this.nameOidMap[name].oid, parser); if (! this.nameOidMap[name]) return; dataType.types.postgres.forEach(name => { // Set parsers for normal data types } return; }); this.oidParserMap.set(arrayOid, arrayParser); this.enumOids.arrayOids.forEach(arrayOid => { }); this.oidParserMap.set(oid, parser); this.enumOids.oids.forEach(oid => { if (dataType.key.toLowerCase() === 'enum') { // Set enum parsers const arrayParser = arrayParserBuilder(parser); const parser = value => dataType.parse(value); // Create parsers for normal or enum data types } return; } this.oidParserMap.set(entry.arrayRangeOid, arrayRangeParser); if (! entry.arrayRangeOid) continue; this.oidParserMap.set(entry.rangeOid, rangeParser); const arrayRangeParser = arrayParserBuilder(rangeParser); const rangeParser = rangeParserBuilder(this.getTypeParser(entry.oid)); if (! entry.rangeOid) continue; const entry = this.nameOidMap[name]; for (const name in this.nameOidMap) { if (dataType.key.toLowerCase() === 'range') { // Set range parsers }; return value => dataType.parse(value, { parser }); const rangeParserBuilder = parser => { }; return value => this.lib.types.arrayParser.create(value, parser).parse(); const arrayParserBuilder = parser => { _refreshTypeParser(dataType) { // Expose this as a method so that the parsing may be updated when the user has added additional, custom types } this.refreshTypeParser(dataTypes.postgres); this._clearTypeParser(); this._clearDynamicOIDs(); this.lib = this.sequelize.config.native ? pgLib.native : pgLib; const pgLib = this._loadDialectModule(pg); super(dialect, sequelize); sequelize.config.port = sequelize.config.port || 5432; constructor(dialect, sequelize) {class ConnectionManager extends AbstractConnectionManager {const { promisify } = require('util');ad3Wj N r y s r 2   ~ ]  i : ,  ~utS.DIi  P9S<fOA. debug('connection acquired'); } else { } reject(new sequelizeErrors.ConnectionError(err)); } else { } break; reject(new sequelizeErrors.ConnectionError(err)); default: break; reject(new sequelizeErrors.InvalidConnectionError(err)); case 'EINVAL': break; reject(new sequelizeErrors.HostNotReachableError(err)); case 'EHOSTUNREACH': break; reject(new sequelizeErrors.HostNotFoundError(err)); case 'ENOTFOUND': break; reject(new sequelizeErrors.ConnectionRefusedError(err)); case 'ECONNREFUSED': switch (err.code) { if (err.code) { if (err) { } connection.connection.removeListener('parameterStatus', parameterHandler); // remove parameter handler if (!this.sequelize.config.native) { responded = true; connection.connect(err => { } connection.connection.on('parameterStatus', parameterHandler); // Receive various server parameters for further configuration if (!this.sequelize.config.native) { connection.once('end', endHandler); // node-postgres does not treat this as an error since no active query was ever emitted // If we didn't ever hear from the client.connect() callback the connection timeout }; } reject(new sequelizeErrors.ConnectionTimedOutError(new Error('Connection timed out'))); if (!responded) { debug('connection timeout'); const endHandler = () => { }; } break; connection['standard_conforming_strings'] = message.parameterValue; case 'standard_conforming_strings': break; } : this.dialect.defaultVersion; ? version this.sequelize.options.databaseVersion = semver.valid(version) const version = semver.coerce(message.parameterValue).version; if (this.sequelize.options.databaseVersion === 0) { case 'server_version': switch (message.parameterName) { const parameterHandler = message => { const connection = new this.lib.Client(connectionConfig); let responded = false; const connection = await new Promise((resolve, reject) => { } ])); 'idle_in_transaction_session_timeout' // Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds. Added in pg v7.17.0 only supported in postgres >= 10 'statement_timeout', // Times out queries after a set time in milliseconds. Added in pg v7.3 'keepAlive', // this feature has been added in pg module v6.0.0, check pg/CHANGELOG.md // This should help with backends incorrectly considering idle clients to be dead and prematurely disconnecting them. 'binary', // see [http://www.postgresql.org/message-id/flat/bc9549a50706040852u27633f41ib1e6b09f8339d845@mail.gmail.com#bc9549a50706040852u27633f41ib1e6b09f8339d845@mail.gmail.com] // (unless you know what you're doing) // !! DO NOT SET THIS TO TRUE !! 'client_encoding', // current locale in the client (LC_CTYPE environment variable on Unix systems) // you can use "auto" to determine the right encoding from the // In addition to the values accepted by the corresponding server,adgxw| , & % K < \ 3  ] ; r #    tpoE^PJI a d;yZRLK-] // Mapping base types and their arrays } continue; if (row.typarray) newEnumOids.arrayOids.push(row.typarray); newEnumOids.oids.push(row.oid); if (row.typtype === 'e') { // Mapping enums, handled separatedly for (const row of result.rows) { const newEnumOids = { oids: [], arrayOids: [] }; const newNameOidMap = {}; } } result = result.pop(); if (result[0].command === 'SET') { if (Array.isArray(result)) { // the SELECT query result. // an array of those two statements. First one is the SET search_path and second is // When searchPath is prepended then two statements are executed and the result is let result = Array.isArray(results) ? results.pop() : results; ); ' WHERE (pg_type.typtype IN(\'b\', \'e\'));' ' FROM pg_type LEFT OUTER JOIN ranges ON pg_type.oid = ranges.rngsubtype' + ' ranges.rngtypname, ranges.rngtypid, ranges.rngtyparray' + 'SELECT pg_type.typname, pg_type.typtype, pg_type.oid, pg_type.typarray,' + ')' + ' FROM pg_range LEFT OUTER JOIN pg_type ON pg_type.oid = pg_range.rngtypid' + ' pg_type.typarray AS rngtyparray, pg_range.rngsubtype' + ' SELECT pg_range.rngtypid, pg_type.typname AS rngtypname,' + 'WITH ranges AS (' + const results = await (connection || this.sequelize).query( } return; if ( (databaseVersion && semver.gte(databaseVersion, supportedVersion)) === false) { // Check for supported version const supportedVersion = '8.3.0'; const databaseVersion = this.sequelize.options.databaseVersion; async _refreshDynamicOIDs(connection) { } return !connection._invalid && !connection._ending; validate(connection) { } return await promisify(callback => connection.end(callback))(); } return; debug('connection tried to disconnect but was already at ENDING state'); if (connection._ending) { async disconnect(connection) { } return connection; }); this.pool.destroy(connection); debug(`connection error ${error.code || error.message}`); connection._invalid = true; connection.on('error', error => { // Don't let a Postgres restart (or error) to take down the whole app } await this._refreshDynamicOIDs(connection); this.enumOids.arrayOids.length === 0) { this.enumOids.oids.length === 0 && if (Object.keys(this.nameOidMap).length === 0 && } await connection.query(query); if (query) { } } query += `SET TIME ZONE INTERVAL '${this.sequelize.options.timezone}' HOUR TO MINUTE;`; } else { query += `SET TIME ZONE '${this.sequelize.options.timezone}';`; if (isZone) { const isZone = !!moment.tz.zone(this.sequelize.options.timezone); if (!this.sequelize.config.keepDefaultTimezone) { } query += `SET client_min_messages TO ${this.sequelize.options.clientMinMessages};`; if (this.sequelize.options.clientMinMessages !== false) { } query += 'SET standard_conforming_strings=on;'; // see https://www.postgresql.org/docs/current/static/runtime-config-compatible.html#GUC-STANDARD-CONFORMING-STRINGS // see https://github.com/sequelize/sequelize/issues/3545 (security issue) // Disable escape characters in strings if (this.sequelize.options.standardConformingStrings !== false && connection['standard_conforming_strings'] !== 'on') { let query = ''; }); }); } resolve(connection); connection.removeListener('end', endHandler);