8 lines
18 KiB
Plaintext
8 lines
18 KiB
Plaintext
|
{
|
||
|
"version": 3,
|
||
|
"sources": ["../../../src/dialects/postgres/connection-manager.js"],
|
||
|
"sourcesContent": ["'use strict';\n\nconst _ = require('lodash');\nconst AbstractConnectionManager = require('../abstract/connection-manager');\nconst { logger } = require('../../utils/logger');\nconst debug = logger.debugContext('connection:pg');\nconst sequelizeErrors = require('../../errors');\nconst semver = require('semver');\nconst dataTypes = require('../../data-types');\nconst momentTz = require('moment-timezone');\nconst { promisify } = require('util');\n\nclass ConnectionManager extends AbstractConnectionManager {\n constructor(dialect, sequelize) {\n sequelize.config.port = sequelize.config.port || 5432;\n super(dialect, sequelize);\n\n const pgLib = this._loadDialectModule('pg');\n this.lib = this.sequelize.config.native ? pgLib.native : pgLib;\n\n this._clearDynamicOIDs();\n this._clearTypeParser();\n this.refreshTypeParser(dataTypes.postgres);\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 const arrayParserBuilder = parser => {\n return value => this.lib.types.arrayParser.create(value, parser).parse();\n };\n const rangeParserBuilder = parser => {\n return value => dataType.parse(value, { parser });\n };\n\n // Set range parsers\n if (dataType.key.toLowerCase() === 'range') {\n for (const name in this.nameOidMap) {\n const entry = this.nameOidMap[name];\n if (! entry.rangeOid) continue;\n\n const rangeParser = rangeParserBuilder(this.getTypeParser(entry.oid));\n const arrayRangeParser = arrayParserBuilder(rangeParser);\n\n this.oidParserMap.set(entry.rangeOid, rangeParser);\n if (! entry.arrayRangeOid) continue;\n this.oidParserMap.set(entry.arrayRangeOid, arrayRangeParser);\n }\n return;\n }\n\n // Create parsers for normal or enum data types\n const parser = value => dataType.parse(value);\n const arrayParser = arrayParserBuilder(parser);\n\n // Set enum parsers\n if (dataType.key.toLowerCase() === 'enum') {\n this.enumOids.oids.forEach(oid => {\n this.oidParserMap.set(oid, parser);\n });\n this.enumOids.arrayOids.forEach(arrayOid => {\n this.oidParserMap.set(arrayOid, arrayParser);\n });\n return;\n }\n\n // Set parsers for normal data types\n dataType.types.postgres.forEach(name => {\n if (! this.nameOidMap[name]) return;\n this.oidParserMap.set(this.nameOidMap[name].oid, parser);\n\n if (! this.nameOidMap[name].arrayOid) return;\n this.oidParserMap.set(this.nameOidMap[name].arrayOid, arrayParser);\n });\n }\n\n _clearTypeParser() {\n this.oidParserMap = new Map();\n }\n\n getTypeParser(oid, ...args) {\n if (this.oidParserMap.get(oid)) return this.oidParserMap.get(oid);\n\n return this.lib.types.getTypeParser(oid, ...args);\n }\n\n async connect(config) {\n config.user = config.username;\n const connectionConfig = _.pick(config, [\n 'user', 'password', 'host', 'database', 'port'\n ]);\n\n connectionConfig.types = {\n getTypeParser: ConnectionManager.prototype.getTypeParser.bind(this)\n };\n\n if (config.dialectOptions) {\n _.merge(connectionConfig,\n _.pick(config.dialectOptions, [\n // see [http://www.postgresql.org/docs/9.3/static/runtime-config-logging.html#GUC-APPLICATION-NAME]\n 'application_name',\n // choose the SSL mode with the PGSSLMODE environment variable\n // object format: [https://github.com/brianc/node-postgres/blob/ee19e74ffa6309c9c5e8e01746261a8f651661f8/lib/connection.js#L79]\n // see also [http://www.postgresql.org/docs/9.3/static/libpq-ssl.html]\n 'ssl',\n // In addition to the values accepted by the corresponding server,\n // you can use \"auto\" to determine the right encoding from the\n // current locale in the client (LC_CTYPE environment variable on Unix systems)\n 'client_encoding',\n // !! DO NOT SET THIS TO TRUE !!\
|
||
|
"mappings": ";AAEA,MAAM,IAAI,QAAQ;AAClB,MAAM,4BAA4B,QAAQ;AAC1C,MAAM,EAAE,WAAW,QAAQ;AAC3B,MAAM,QAAQ,OAAO,aAAa;AAClC,MAAM,kBAAkB,QAAQ;AAChC,MAAM,SAAS,QAAQ;AACvB,MAAM,YAAY,QAAQ;AAC1B,MAAM,WAAW,QAAQ;AACzB,MAAM,EAAE,cAAc,QAAQ;AAE9B,gCAAgC,0BAA0B;AAAA,EACxD,YAAY,SAAS,WAAW;AAC9B,cAAU,OAAO,O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