API/api.medcify.app/node_modules/sequelize/lib/dialects/postgres/query-generator.js.map

8 lines
49 KiB
Plaintext
Raw Normal View History

2022-09-26 06:11:44 +00:00
{
"version": 3,
"sources": ["../../../src/dialects/postgres/query-generator.js"],
"sourcesContent": ["'use strict';\n\nconst Utils = require('../../utils');\nconst util = require('util');\nconst DataTypes = require('../../data-types');\nconst AbstractQueryGenerator = require('../abstract/query-generator');\nconst semver = require('semver');\nconst _ = require('lodash');\n\n/**\n * list of reserved words in PostgreSQL 10\n * source: https://www.postgresql.org/docs/10/static/sql-keywords-appendix.html\n *\n * @private\n */\nconst POSTGRES_RESERVED_WORDS = 'all,analyse,analyze,and,any,array,as,asc,asymmetric,authorization,binary,both,case,cast,check,collate,collation,column,concurrently,constraint,create,cross,current_catalog,current_date,current_role,current_schema,current_time,current_timestamp,current_user,default,deferrable,desc,distinct,do,else,end,except,false,fetch,for,foreign,freeze,from,full,grant,group,having,ilike,in,initially,inner,intersect,into,is,isnull,join,lateral,leading,left,like,limit,localtime,localtimestamp,natural,not,notnull,null,offset,on,only,or,order,outer,overlaps,placing,primary,references,returning,right,select,session_user,similar,some,symmetric,table,tablesample,then,to,trailing,true,union,unique,user,using,variadic,verbose,when,where,window,with'.split(',');\n\nclass PostgresQueryGenerator extends AbstractQueryGenerator {\n setSearchPath(searchPath) {\n return `SET search_path to ${searchPath};`;\n }\n\n createDatabaseQuery(databaseName, options) {\n options = {\n encoding: null,\n collate: null,\n ...options\n };\n\n const values = {\n database: this.quoteTable(databaseName),\n encoding: options.encoding ? ` ENCODING = ${this.escape(options.encoding)}` : '',\n collation: options.collate ? ` LC_COLLATE = ${this.escape(options.collate)}` : '',\n ctype: options.ctype ? ` LC_CTYPE = ${this.escape(options.ctype)}` : '',\n template: options.template ? ` TEMPLATE = ${this.escape(options.template)}` : ''\n };\n\n return `CREATE DATABASE ${values.database}${values.encoding}${values.collation}${values.ctype}${values.template};`;\n }\n\n dropDatabaseQuery(databaseName) {\n return `DROP DATABASE IF EXISTS ${this.quoteTable(databaseName)};`;\n }\n\n createSchema(schema) {\n const databaseVersion = _.get(this, 'sequelize.options.databaseVersion', 0);\n\n if (databaseVersion && semver.gte(databaseVersion, '9.2.0')) {\n return `CREATE SCHEMA IF NOT EXISTS ${schema};`;\n }\n\n return `CREATE SCHEMA ${schema};`;\n }\n\n dropSchema(schema) {\n return `DROP SCHEMA IF EXISTS ${schema} CASCADE;`;\n }\n\n showSchemasQuery() {\n return \"SELECT schema_name FROM information_schema.schemata WHERE schema_name <> 'information_schema' AND schema_name != 'public' AND schema_name !~ E'^pg_';\";\n }\n\n versionQuery() {\n return 'SHOW SERVER_VERSION';\n }\n\n createTableQuery(tableName, attributes, options) {\n options = { ...options };\n\n //Postgres 9.0 does not support CREATE TABLE IF NOT EXISTS, 9.1 and above do\n const databaseVersion = _.get(this, 'sequelize.options.databaseVersion', 0);\n const attrStr = [];\n let comments = '';\n let columnComments = '';\n\n const quotedTable = this.quoteTable(tableName);\n\n if (options.comment && typeof options.comment === 'string') {\n comments += `; COMMENT ON TABLE ${quotedTable} IS ${this.escape(options.comment)}`;\n }\n\n for (const attr in attributes) {\n const quotedAttr = this.quoteIdentifier(attr);\n const i = attributes[attr].indexOf('COMMENT ');\n if (i !== -1) {\n // Move comment to a separate query\n const escapedCommentText = this.escape(attributes[attr].substring(i + 8));\n columnComments += `; COMMENT ON COLUMN ${quotedTable}.${quotedAttr} IS ${escapedCommentText}`;\n attributes[attr] = attributes[attr].substring(0, i);\n }\n\n const dataType = this.dataTypeMapping(tableName, attr, attributes[attr]);\n attrStr.push(`${quotedAttr} ${dataType}`);\n }\n\n\n let attributesClause = attrStr.join(', ');\n\n if (options.uniqueKeys) {\n _.each(
"mappings": ";;;;;;;;;;;;;;;;;AAEA,MAAM,QAAQ,QAAQ;AACtB,MAAM,OAAO,QAAQ;AACrB,MAAM,YAAY,QAAQ;AAC1B,MAAM,yBAAyB,QAAQ;AACvC,MAAM,SAAS,QAAQ;AACvB,MAAM,IAAI,QAA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