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

8 lines
24 KiB
Plaintext
Raw Normal View History

2022-09-26 06:11:44 +00:00
{
"version": 3,
"sources": ["../../../src/dialects/sqlite/query-generator.js"],
"sourcesContent": ["'use strict';\n\nconst Utils = require('../../utils');\nconst Transaction = require('../../transaction');\nconst _ = require('lodash');\nconst MySqlQueryGenerator = require('../mysql/query-generator');\nconst AbstractQueryGenerator = require('../abstract/query-generator');\n\nclass SQLiteQueryGenerator extends MySqlQueryGenerator {\n createSchema() {\n return \"SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence';\";\n }\n\n showSchemasQuery() {\n return \"SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence';\";\n }\n\n versionQuery() {\n return 'SELECT sqlite_version() as `version`';\n }\n\n createTableQuery(tableName, attributes, options) {\n options = options || {};\n\n const primaryKeys = [];\n const needsMultiplePrimaryKeys = Object.values(attributes).filter(definition => definition.includes('PRIMARY KEY')).length > 1;\n const attrArray = [];\n\n for (const attr in attributes) {\n if (Object.prototype.hasOwnProperty.call(attributes, attr)) {\n const dataType = attributes[attr];\n const containsAutoIncrement = dataType.includes('AUTOINCREMENT');\n\n let dataTypeString = dataType;\n if (dataType.includes('PRIMARY KEY')) {\n if (dataType.includes('INT')) {\n // Only INTEGER is allowed for primary key, see https://github.com/sequelize/sequelize/issues/969 (no lenght, unsigned etc)\n dataTypeString = containsAutoIncrement ? 'INTEGER PRIMARY KEY AUTOINCREMENT' : 'INTEGER PRIMARY KEY';\n\n if (dataType.includes(' REFERENCES')) {\n dataTypeString += dataType.substr(dataType.indexOf(' REFERENCES'));\n }\n }\n\n if (needsMultiplePrimaryKeys) {\n primaryKeys.push(attr);\n if (dataType.includes('NOT NULL')) {\n dataTypeString = dataType.replace(' PRIMARY KEY', '');\n } else {\n dataTypeString = dataType.replace('PRIMARY KEY', 'NOT NULL');\n }\n }\n }\n attrArray.push(`${this.quoteIdentifier(attr)} ${dataTypeString}`);\n }\n }\n\n const table = this.quoteTable(tableName);\n let attrStr = attrArray.join(', ');\n const pkString = primaryKeys.map(pk => this.quoteIdentifier(pk)).join(', ');\n\n if (options.uniqueKeys) {\n _.each(options.uniqueKeys, columns => {\n if (columns.customIndex) {\n attrStr += `, UNIQUE (${columns.fields.map(field => this.quoteIdentifier(field)).join(', ')})`;\n }\n });\n }\n\n if (pkString.length > 0) {\n attrStr += `, PRIMARY KEY (${pkString})`;\n }\n\n const sql = `CREATE TABLE IF NOT EXISTS ${table} (${attrStr});`;\n return this.replaceBooleanDefaults(sql);\n }\n\n booleanValue(value) {\n return value ? 1 : 0;\n }\n\n /**\n * Check whether the statmement is json function or simple path\n *\n * @param {string} stmt The statement to validate\n * @returns {boolean} true if the given statement is json function\n * @throws {Error} throw if the statement looks like json function but has invalid token\n */\n _checkValidJsonStatement(stmt) {\n if (typeof stmt !== 'string') {\n return false;\n }\n\n // https://sqlite.org/json1.html\n const jsonFunctionRegex = /^\\s*(json(?:_[a-z]+){0,2})\\([^)]*\\)/i;\n const tokenCaptureRegex = /^\\s*((?:([`\"'])(?:(?!\\2).|\\2{2})*\\2)|[\\w\\d\\s]+|[().,;+-])/i;\n\n let currentIndex = 0;\n let openingBrackets = 0;\n let closingBrackets = 0;\n let hasJsonFunction = false;\n let hasInvalidToken = false;\n\n while (currentIndex < stmt.length) {\n const string = stmt.substr(currentIndex);\n const functionMatches = jsonFunctionRegex.exec(string);\n if (functionMatches) {\n currentIndex += functionMatches[0].indexOf('(');\n hasJsonFunction = true;\n continue;\n }\n\n const tokenMatches = tokenCaptureRegex.exec(string);\n if (tokenMatches) {\n const capturedToken = to
"mappings": ";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,QAAQ,QAAQ;AACtB,MAAM,cAAc,QAAQ;AAC5B,MAAM,IAAI,QAAQ;AAClB,MAAM,sBAAsB,QAAQ;AACpC,MAAM,yBAAyB,QAAQ;AAEvC,mCAAmC,oBAAoB;AAAA,EACrD,eAAe;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