.
This commit is contained in:
		
							
								
								
									
										118
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/connection-manager.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/connection-manager.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,118 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
var __defProp = Object.defineProperty;
 | 
			
		||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
 | 
			
		||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
 | 
			
		||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
 | 
			
		||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
 | 
			
		||||
var __spreadValues = (a, b) => {
 | 
			
		||||
  for (var prop in b || (b = {}))
 | 
			
		||||
    if (__hasOwnProp.call(b, prop))
 | 
			
		||||
      __defNormalProp(a, prop, b[prop]);
 | 
			
		||||
  if (__getOwnPropSymbols)
 | 
			
		||||
    for (var prop of __getOwnPropSymbols(b)) {
 | 
			
		||||
      if (__propIsEnum.call(b, prop))
 | 
			
		||||
        __defNormalProp(a, prop, b[prop]);
 | 
			
		||||
    }
 | 
			
		||||
  return a;
 | 
			
		||||
};
 | 
			
		||||
const semver = require("semver");
 | 
			
		||||
const AbstractConnectionManager = require("../abstract/connection-manager");
 | 
			
		||||
const SequelizeErrors = require("../../errors");
 | 
			
		||||
const { logger } = require("../../utils/logger");
 | 
			
		||||
const DataTypes = require("../../data-types").mariadb;
 | 
			
		||||
const momentTz = require("moment-timezone");
 | 
			
		||||
const debug = logger.debugContext("connection:mariadb");
 | 
			
		||||
const parserStore = require("../parserStore")("mariadb");
 | 
			
		||||
class ConnectionManager extends AbstractConnectionManager {
 | 
			
		||||
  constructor(dialect, sequelize) {
 | 
			
		||||
    sequelize.config.port = sequelize.config.port || 3306;
 | 
			
		||||
    super(dialect, sequelize);
 | 
			
		||||
    this.lib = this._loadDialectModule("mariadb");
 | 
			
		||||
    this.refreshTypeParser(DataTypes);
 | 
			
		||||
  }
 | 
			
		||||
  static _typecast(field, next) {
 | 
			
		||||
    if (parserStore.get(field.type)) {
 | 
			
		||||
      return parserStore.get(field.type)(field, this.sequelize.options, next);
 | 
			
		||||
    }
 | 
			
		||||
    return next();
 | 
			
		||||
  }
 | 
			
		||||
  _refreshTypeParser(dataType) {
 | 
			
		||||
    parserStore.refresh(dataType);
 | 
			
		||||
  }
 | 
			
		||||
  _clearTypeParser() {
 | 
			
		||||
    parserStore.clear();
 | 
			
		||||
  }
 | 
			
		||||
  async connect(config) {
 | 
			
		||||
    let tzOffset = this.sequelize.options.timezone;
 | 
			
		||||
    tzOffset = /\//.test(tzOffset) ? momentTz.tz(tzOffset).format("Z") : tzOffset;
 | 
			
		||||
    const connectionConfig = __spreadValues({
 | 
			
		||||
      host: config.host,
 | 
			
		||||
      port: config.port,
 | 
			
		||||
      user: config.username,
 | 
			
		||||
      password: config.password,
 | 
			
		||||
      database: config.database,
 | 
			
		||||
      timezone: tzOffset,
 | 
			
		||||
      typeCast: ConnectionManager._typecast.bind(this),
 | 
			
		||||
      bigNumberStrings: false,
 | 
			
		||||
      supportBigNumbers: true,
 | 
			
		||||
      foundRows: false
 | 
			
		||||
    }, config.dialectOptions);
 | 
			
		||||
    if (!this.sequelize.config.keepDefaultTimezone) {
 | 
			
		||||
      if (connectionConfig.initSql) {
 | 
			
		||||
        if (!Array.isArray(connectionConfig.initSql)) {
 | 
			
		||||
          connectionConfig.initSql = [connectionConfig.initSql];
 | 
			
		||||
        }
 | 
			
		||||
        connectionConfig.initSql.push(`SET time_zone = '${tzOffset}'`);
 | 
			
		||||
      } else {
 | 
			
		||||
        connectionConfig.initSql = `SET time_zone = '${tzOffset}'`;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
      const connection = await this.lib.createConnection(connectionConfig);
 | 
			
		||||
      this.sequelize.options.databaseVersion = semver.coerce(connection.serverVersion()).version;
 | 
			
		||||
      debug("connection acquired");
 | 
			
		||||
      connection.on("error", (error) => {
 | 
			
		||||
        switch (error.code) {
 | 
			
		||||
          case "ESOCKET":
 | 
			
		||||
          case "ECONNRESET":
 | 
			
		||||
          case "EPIPE":
 | 
			
		||||
          case "PROTOCOL_CONNECTION_LOST":
 | 
			
		||||
            this.pool.destroy(connection);
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
      return connection;
 | 
			
		||||
    } catch (err) {
 | 
			
		||||
      switch (err.code) {
 | 
			
		||||
        case "ECONNREFUSED":
 | 
			
		||||
          throw new SequelizeErrors.ConnectionRefusedError(err);
 | 
			
		||||
        case "ER_ACCESS_DENIED_ERROR":
 | 
			
		||||
        case "ER_ACCESS_DENIED_NO_PASSWORD_ERROR":
 | 
			
		||||
          throw new SequelizeErrors.AccessDeniedError(err);
 | 
			
		||||
        case "ENOTFOUND":
 | 
			
		||||
          throw new SequelizeErrors.HostNotFoundError(err);
 | 
			
		||||
        case "EHOSTUNREACH":
 | 
			
		||||
        case "ENETUNREACH":
 | 
			
		||||
        case "EADDRNOTAVAIL":
 | 
			
		||||
          throw new SequelizeErrors.HostNotReachableError(err);
 | 
			
		||||
        case "EINVAL":
 | 
			
		||||
          throw new SequelizeErrors.InvalidConnectionError(err);
 | 
			
		||||
        default:
 | 
			
		||||
          throw new SequelizeErrors.ConnectionError(err);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  async disconnect(connection) {
 | 
			
		||||
    if (!connection.isValid()) {
 | 
			
		||||
      debug("connection tried to disconnect but was already at CLOSED state");
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    return await connection.end();
 | 
			
		||||
  }
 | 
			
		||||
  validate(connection) {
 | 
			
		||||
    return connection && connection.isValid();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
module.exports = ConnectionManager;
 | 
			
		||||
module.exports.ConnectionManager = ConnectionManager;
 | 
			
		||||
module.exports.default = ConnectionManager;
 | 
			
		||||
//# sourceMappingURL=connection-manager.js.map
 | 
			
		||||
							
								
								
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/connection-manager.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/connection-manager.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
  "version": 3,
 | 
			
		||||
  "sources": ["../../../src/dialects/mariadb/connection-manager.js"],
 | 
			
		||||
  "sourcesContent": ["'use strict';\n\nconst semver = require('semver');\nconst AbstractConnectionManager = require('../abstract/connection-manager');\nconst SequelizeErrors = require('../../errors');\nconst { logger } = require('../../utils/logger');\nconst DataTypes = require('../../data-types').mariadb;\nconst momentTz = require('moment-timezone');\nconst debug = logger.debugContext('connection:mariadb');\nconst parserStore = require('../parserStore')('mariadb');\n\n/**\n * MariaDB Connection Manager\n *\n * Get connections, validate and disconnect them.\n * AbstractConnectionManager pooling use it to handle MariaDB specific connections\n * Use https://github.com/MariaDB/mariadb-connector-nodejs to connect with MariaDB server\n *\n * @private\n */\nclass ConnectionManager extends AbstractConnectionManager {\n  constructor(dialect, sequelize) {\n    sequelize.config.port = sequelize.config.port || 3306;\n    super(dialect, sequelize);\n    this.lib = this._loadDialectModule('mariadb');\n    this.refreshTypeParser(DataTypes);\n  }\n\n  static _typecast(field, next) {\n    if (parserStore.get(field.type)) {\n      return parserStore.get(field.type)(field, this.sequelize.options, next);\n    }\n    return next();\n  }\n\n  _refreshTypeParser(dataType) {\n    parserStore.refresh(dataType);\n  }\n\n  _clearTypeParser() {\n    parserStore.clear();\n  }\n\n  /**\n   * Connect with MariaDB 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    // Named timezone is not supported in mariadb, convert to offset\n    let tzOffset = this.sequelize.options.timezone;\n    tzOffset = /\\//.test(tzOffset) ? momentTz.tz(tzOffset).format('Z')\n      : tzOffset;\n\n    const connectionConfig = {\n      host: config.host,\n      port: config.port,\n      user: config.username,\n      password: config.password,\n      database: config.database,\n      timezone: tzOffset,\n      typeCast: ConnectionManager._typecast.bind(this),\n      bigNumberStrings: false,\n      supportBigNumbers: true,\n      foundRows: false,\n      ...config.dialectOptions\n    };\n\n    if (!this.sequelize.config.keepDefaultTimezone) {\n      // set timezone for this connection\n      if (connectionConfig.initSql) {\n        if (!Array.isArray(\n          connectionConfig.initSql)) {\n          connectionConfig.initSql = [connectionConfig.initSql];\n        }\n        connectionConfig.initSql.push(`SET time_zone = '${tzOffset}'`);\n      } else {\n        connectionConfig.initSql = `SET time_zone = '${tzOffset}'`;\n      }\n    }\n\n    try {\n      const connection = await this.lib.createConnection(connectionConfig);\n      this.sequelize.options.databaseVersion = semver.coerce(connection.serverVersion()).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      return connection;\n    } catch (err) {\n      switch (err.code) {\n        case 'ECONNREFUSED':\n          throw new SequelizeErrors.ConnectionRefusedError(err);\n        case 'ER_ACCESS_DENIED_ERROR':\n        case 'ER_ACCESS_DENIED_NO_PASSWORD_ERROR':\n          throw new SequelizeErrors.AccessDeniedError(err);\n        case 'ENOTFOUND':\n          throw new SequelizeErrors.HostNotFoundError(err);\n        case 'EHOSTUNREACH':\n        case 'ENETUNREACH':\n        case 'EADDRNOTAVAIL':\n          throw new SequelizeErrors.HostNotReachableError(err);\n        case 'EINVAL':\n          throw new SequelizeErrors.InvalidConnectionError(err);\n        default:\n          throw new SequelizeErrors.ConnectionError(err);\n      }\n    }\n  }\n\n  async disconnect(connection) {\n    // Don't disconnect connections with CLOSED state\n    if (!connection.isValid()) {\n      debug('connection tried to disconnect but was already at CLOSED state');\n      return;\n    }\n    return await connection.end();\n  }\n\n  validate(connection) {\n    return connection && connection.isValid();\n  }\n}\n\nmodule.exports = ConnectionManager;\nmodule.exports.ConnectionManager = ConnectionManager;\nmodule.exports.default = ConnectionManager;\n"],
 | 
			
		||||
  "mappings": ";;;;;;;;;;;;;;;;;AAEA,MAAM,SAAS,QAAQ;AACvB,MAAM,4BAA4B,QAAQ;AAC1C,MAAM,kBAAkB,QAAQ;AAChC,MAAM,EAAE,WAAW,QAAQ;AAC3B,MAAM,YAAY,QAAQ,oBAAoB;AAC9C,MAAM,WAAW,QAAQ;AACzB,MAAM,QAAQ,OAAO,aAAa;AAClC,MAAM,cAAc,QAAQ,kBAAkB;AAW9C,gCAAgC,0BAA0B;AAAA,EACxD,YAAY,SAAS,WAAW;AAC9B,cAAU,OAAO,OAAO,UAAU,OAAO,QAAQ;AACjD,UAAM,SAAS;AACf,SAAK,MAAM,KAAK,mBAAmB;AACnC,SAAK,kBAAkB;AAAA;AAAA,SAGlB,UAAU,OAAO,MAAM;AAC5B,QAAI,YAAY,IAAI,MAAM,OAAO;AAC/B,aAAO,YAAY,IAAI,MAAM,MAAM,OAAO,KAAK,UAAU,SAAS;AAAA;AAEpE,WAAO;AAAA;AAAA,EAGT,mBAAmB,UAAU;AAC3B,gBAAY,QAAQ;AAAA;AAAA,EAGtB,mBAAmB;AACjB,gBAAY;AAAA;AAAA,QAYR,QAAQ,QAAQ;AAEpB,QAAI,WAAW,KAAK,UAAU,QAAQ;AACtC,eAAW,KAAK,KAAK,YAAY,SAAS,GAAG,UAAU,OAAO,OAC1D;AAEJ,UAAM,mBAAmB;AAAA,MACvB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,UAAU,OAAO;AAAA,MACjB,UAAU,OAAO;AAAA,MACjB,UAAU;AAAA,MACV,UAAU,kBAAkB,UAAU,KAAK;AAAA,MAC3C,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,WAAW;AAAA,OACR,OAAO;AAGZ,QAAI,CAAC,KAAK,UAAU,OAAO,qBAAqB;AAE9C,UAAI,iBAAiB,SAAS;AAC5B,YAAI,CAAC,MAAM,QACT,iBAAiB,UAAU;AAC3B,2BAAiB,UAAU,CAAC,iBAAiB;AAAA;AAE/C,yBAAiB,QAAQ,KAAK,oBAAoB;AAAA,aAC7C;AACL,yBAAiB,UAAU,oBAAoB;AAAA;AAAA;AAInD,QAAI;AACF,YAAM,aAAa,MAAM,KAAK,IAAI,iBAAiB;AACnD,WAAK,UAAU,QAAQ,kBAAkB,OAAO,OAAO,WAAW,iBAAiB;AAEnF,YAAM;AACN,iBAAW,GAAG,SAAS,WAAS;AAC9B,gBAAQ,MAAM;AAAA,eACP;AAAA,eACA;AAAA,eACA;AAAA,eACA;AACH,iBAAK,KAAK,QAAQ;AAAA;AAAA;AAGxB,aAAO;AAAA,aACA,KAAP;AACA,cAAQ,IAAI;AAAA,aACL;AACH,gBAAM,IAAI,gBAAgB,uBAAuB;AAAA,aAC9C;AAAA,aACA;AACH,gBAAM,IAAI,gBAAgB,kBAAkB;AAAA,aACzC;AACH,gBAAM,IAAI,gBAAgB,kBAAkB;AAAA,aACzC;AAAA,aACA;AAAA,aACA;AACH,gBAAM,IAAI,gBAAgB,sBAAsB;AAAA,aAC7C;AACH,gBAAM,IAAI,gBAAgB,uBAAuB;AAAA;AAEjD,gBAAM,IAAI,gBAAgB,gBAAgB;AAAA;AAAA;AAAA;AAAA,QAK5C,WAAW,YAAY;AAE3B,QAAI,CAAC,WAAW,WAAW;AACzB,YAAM;AACN;AAAA;AAEF,WAAO,MAAM,WAAW;AAAA;AAAA,EAG1B,SAAS,YAAY;AACnB,WAAO,cAAc,WAAW;AAAA;AAAA;AAIpC,OAAO,UAAU;AACjB,OAAO,QAAQ,oBAAoB;AACnC,OAAO,QAAQ,UAAU;",
 | 
			
		||||
  "names": []
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										115
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/data-types.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/data-types.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,115 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
const wkx = require("wkx");
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
const momentTz = require("moment-timezone");
 | 
			
		||||
const moment = require("moment");
 | 
			
		||||
module.exports = (BaseTypes) => {
 | 
			
		||||
  BaseTypes.ABSTRACT.prototype.dialectTypes = "https://mariadb.com/kb/en/library/resultset/#field-types";
 | 
			
		||||
  BaseTypes.DATE.types.mariadb = ["DATETIME"];
 | 
			
		||||
  BaseTypes.STRING.types.mariadb = ["VAR_STRING"];
 | 
			
		||||
  BaseTypes.CHAR.types.mariadb = ["STRING"];
 | 
			
		||||
  BaseTypes.TEXT.types.mariadb = ["BLOB"];
 | 
			
		||||
  BaseTypes.TINYINT.types.mariadb = ["TINY"];
 | 
			
		||||
  BaseTypes.SMALLINT.types.mariadb = ["SHORT"];
 | 
			
		||||
  BaseTypes.MEDIUMINT.types.mariadb = ["INT24"];
 | 
			
		||||
  BaseTypes.INTEGER.types.mariadb = ["LONG"];
 | 
			
		||||
  BaseTypes.BIGINT.types.mariadb = ["LONGLONG"];
 | 
			
		||||
  BaseTypes.FLOAT.types.mariadb = ["FLOAT"];
 | 
			
		||||
  BaseTypes.TIME.types.mariadb = ["TIME"];
 | 
			
		||||
  BaseTypes.DATEONLY.types.mariadb = ["DATE"];
 | 
			
		||||
  BaseTypes.BOOLEAN.types.mariadb = ["TINY"];
 | 
			
		||||
  BaseTypes.BLOB.types.mariadb = ["TINYBLOB", "BLOB", "LONGBLOB"];
 | 
			
		||||
  BaseTypes.DECIMAL.types.mariadb = ["NEWDECIMAL"];
 | 
			
		||||
  BaseTypes.UUID.types.mariadb = false;
 | 
			
		||||
  BaseTypes.ENUM.types.mariadb = false;
 | 
			
		||||
  BaseTypes.REAL.types.mariadb = ["DOUBLE"];
 | 
			
		||||
  BaseTypes.DOUBLE.types.mariadb = ["DOUBLE"];
 | 
			
		||||
  BaseTypes.GEOMETRY.types.mariadb = ["GEOMETRY"];
 | 
			
		||||
  BaseTypes.JSON.types.mariadb = ["JSON"];
 | 
			
		||||
  class DECIMAL extends BaseTypes.DECIMAL {
 | 
			
		||||
    toSql() {
 | 
			
		||||
      let definition = super.toSql();
 | 
			
		||||
      if (this._unsigned) {
 | 
			
		||||
        definition += " UNSIGNED";
 | 
			
		||||
      }
 | 
			
		||||
      if (this._zerofill) {
 | 
			
		||||
        definition += " ZEROFILL";
 | 
			
		||||
      }
 | 
			
		||||
      return definition;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  class DATE extends BaseTypes.DATE {
 | 
			
		||||
    toSql() {
 | 
			
		||||
      return this._length ? `DATETIME(${this._length})` : "DATETIME";
 | 
			
		||||
    }
 | 
			
		||||
    _stringify(date, options) {
 | 
			
		||||
      if (!moment.isMoment(date)) {
 | 
			
		||||
        date = this._applyTimezone(date, options);
 | 
			
		||||
      }
 | 
			
		||||
      return date.format("YYYY-MM-DD HH:mm:ss.SSS");
 | 
			
		||||
    }
 | 
			
		||||
    static parse(value, options) {
 | 
			
		||||
      value = value.string();
 | 
			
		||||
      if (value === null) {
 | 
			
		||||
        return value;
 | 
			
		||||
      }
 | 
			
		||||
      if (momentTz.tz.zone(options.timezone)) {
 | 
			
		||||
        value = momentTz.tz(value, options.timezone).toDate();
 | 
			
		||||
      } else {
 | 
			
		||||
        value = new Date(`${value} ${options.timezone}`);
 | 
			
		||||
      }
 | 
			
		||||
      return value;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  class DATEONLY extends BaseTypes.DATEONLY {
 | 
			
		||||
    static parse(value) {
 | 
			
		||||
      return value.string();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  class UUID extends BaseTypes.UUID {
 | 
			
		||||
    toSql() {
 | 
			
		||||
      return "CHAR(36) BINARY";
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  class GEOMETRY extends BaseTypes.GEOMETRY {
 | 
			
		||||
    constructor(type, srid) {
 | 
			
		||||
      super(type, srid);
 | 
			
		||||
      if (_.isEmpty(this.type)) {
 | 
			
		||||
        this.sqlType = this.key;
 | 
			
		||||
      } else {
 | 
			
		||||
        this.sqlType = this.type;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    static parse(value) {
 | 
			
		||||
      value = value.buffer();
 | 
			
		||||
      if (!value || value.length === 0) {
 | 
			
		||||
        return null;
 | 
			
		||||
      }
 | 
			
		||||
      value = value.slice(4);
 | 
			
		||||
      return wkx.Geometry.parse(value).toGeoJSON({ shortCrs: true });
 | 
			
		||||
    }
 | 
			
		||||
    toSql() {
 | 
			
		||||
      return this.sqlType;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  class ENUM extends BaseTypes.ENUM {
 | 
			
		||||
    toSql(options) {
 | 
			
		||||
      return `ENUM(${this.values.map((value) => options.escape(value)).join(", ")})`;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  class JSONTYPE extends BaseTypes.JSON {
 | 
			
		||||
    _stringify(value, options) {
 | 
			
		||||
      return options.operation === "where" && typeof value === "string" ? value : JSON.stringify(value);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return {
 | 
			
		||||
    ENUM,
 | 
			
		||||
    DATE,
 | 
			
		||||
    DATEONLY,
 | 
			
		||||
    UUID,
 | 
			
		||||
    GEOMETRY,
 | 
			
		||||
    DECIMAL,
 | 
			
		||||
    JSON: JSONTYPE
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
//# sourceMappingURL=data-types.js.map
 | 
			
		||||
							
								
								
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/data-types.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/data-types.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
  "version": 3,
 | 
			
		||||
  "sources": ["../../../src/dialects/mariadb/data-types.js"],
 | 
			
		||||
  "sourcesContent": ["'use strict';\n\nconst wkx = require('wkx');\nconst _ = require('lodash');\nconst momentTz = require('moment-timezone');\nconst moment = require('moment');\n\nmodule.exports = BaseTypes => {\n  BaseTypes.ABSTRACT.prototype.dialectTypes = 'https://mariadb.com/kb/en/library/resultset/#field-types';\n\n  /**\n   * types: [buffer_type, ...]\n   *\n   * @see documentation : https://mariadb.com/kb/en/library/resultset/#field-types\n   * @see connector implementation : https://github.com/MariaDB/mariadb-connector-nodejs/blob/master/lib/const/field-type.js\n   */\n\n  BaseTypes.DATE.types.mariadb = ['DATETIME'];\n  BaseTypes.STRING.types.mariadb = ['VAR_STRING'];\n  BaseTypes.CHAR.types.mariadb = ['STRING'];\n  BaseTypes.TEXT.types.mariadb = ['BLOB'];\n  BaseTypes.TINYINT.types.mariadb = ['TINY'];\n  BaseTypes.SMALLINT.types.mariadb = ['SHORT'];\n  BaseTypes.MEDIUMINT.types.mariadb = ['INT24'];\n  BaseTypes.INTEGER.types.mariadb = ['LONG'];\n  BaseTypes.BIGINT.types.mariadb = ['LONGLONG'];\n  BaseTypes.FLOAT.types.mariadb = ['FLOAT'];\n  BaseTypes.TIME.types.mariadb = ['TIME'];\n  BaseTypes.DATEONLY.types.mariadb = ['DATE'];\n  BaseTypes.BOOLEAN.types.mariadb = ['TINY'];\n  BaseTypes.BLOB.types.mariadb = ['TINYBLOB', 'BLOB', 'LONGBLOB'];\n  BaseTypes.DECIMAL.types.mariadb = ['NEWDECIMAL'];\n  BaseTypes.UUID.types.mariadb = false;\n  BaseTypes.ENUM.types.mariadb = false;\n  BaseTypes.REAL.types.mariadb = ['DOUBLE'];\n  BaseTypes.DOUBLE.types.mariadb = ['DOUBLE'];\n  BaseTypes.GEOMETRY.types.mariadb = ['GEOMETRY'];\n  BaseTypes.JSON.types.mariadb = ['JSON'];\n\n  class DECIMAL extends BaseTypes.DECIMAL {\n    toSql() {\n      let definition = super.toSql();\n      if (this._unsigned) {\n        definition += ' UNSIGNED';\n      }\n      if (this._zerofill) {\n        definition += ' ZEROFILL';\n      }\n      return definition;\n    }\n  }\n\n  class DATE extends BaseTypes.DATE {\n    toSql() {\n      return this._length ? `DATETIME(${this._length})` : 'DATETIME';\n    }\n    _stringify(date, options) {\n      if (!moment.isMoment(date)) {\n        date = this._applyTimezone(date, options);\n      }\n\n      return date.format('YYYY-MM-DD HH:mm:ss.SSS');\n    }\n    static parse(value, options) {\n      value = value.string();\n      if (value === null) {\n        return value;\n      }\n      if (momentTz.tz.zone(options.timezone)) {\n        value = momentTz.tz(value, options.timezone).toDate();\n      }\n      else {\n        value = new Date(`${value} ${options.timezone}`);\n      }\n      return value;\n    }\n  }\n\n  class DATEONLY extends BaseTypes.DATEONLY {\n    static parse(value) {\n      return value.string();\n    }\n  }\n\n  class UUID extends BaseTypes.UUID {\n    toSql() {\n      return 'CHAR(36) BINARY';\n    }\n  }\n\n  class GEOMETRY extends BaseTypes.GEOMETRY {\n    constructor(type, srid) {\n      super(type, srid);\n      if (_.isEmpty(this.type)) {\n        this.sqlType = this.key;\n      }\n      else {\n        this.sqlType = this.type;\n      }\n    }\n    static parse(value) {\n      value = value.buffer();\n      // Empty buffer, MySQL doesn't support POINT EMPTY\n      // check, https://dev.mysql.com/worklog/task/?id=2381\n      if (!value || value.length === 0) {\n        return null;\n      }\n      // For some reason, discard the first 4 bytes\n      value = value.slice(4);\n      return wkx.Geometry.parse(value).toGeoJSON({ shortCrs: true });\n    }\n    toSql() {\n      return this.sqlType;\n    }\n  }\n\n  class ENUM extends BaseTypes.ENUM {\n    toSql(options) {\n      return `ENUM(${this.values.map(value => options.escape(value)).join(', ')})`;\n    }\n  }\n\n  class JSONTYPE extends BaseTypes.JSON {\n    _stringify(value, options) {\n      return options.operation === 'where' && typeof value === 'string' ? value\n        : JSON.stringify(value);\n    }\n  }\n\n  return {\n    ENUM,\n    DATE,\n    DATEONLY,\n    UUID,\n    GEOMETRY,\n    DECIMAL,\n    JSON: JSONTYPE\n  };\n};\n"],
 | 
			
		||||
  "mappings": ";AAEA,MAAM,MAAM,QAAQ;AACpB,MAAM,IAAI,QAAQ;AAClB,MAAM,WAAW,QAAQ;AACzB,MAAM,SAAS,QAAQ;AAEvB,OAAO,UAAU,eAAa;AAC5B,YAAU,SAAS,UAAU,eAAe;AAS5C,YAAU,KAAK,MAAM,UAAU,CAAC;AAChC,YAAU,OAAO,MAAM,UAAU,CAAC;AAClC,YAAU,KAAK,MAAM,UAAU,CAAC;AAChC,YAAU,KAAK,MAAM,UAAU,CAAC;AAChC,YAAU,QAAQ,MAAM,UAAU,CAAC;AACnC,YAAU,SAAS,MAAM,UAAU,CAAC;AACpC,YAAU,UAAU,MAAM,UAAU,CAAC;AACrC,YAAU,QAAQ,MAAM,UAAU,CAAC;AACnC,YAAU,OAAO,MAAM,UAAU,CAAC;AAClC,YAAU,MAAM,MAAM,UAAU,CAAC;AACjC,YAAU,KAAK,MAAM,UAAU,CAAC;AAChC,YAAU,SAAS,MAAM,UAAU,CAAC;AACpC,YAAU,QAAQ,MAAM,UAAU,CAAC;AACnC,YAAU,KAAK,MAAM,UAAU,CAAC,YAAY,QAAQ;AACpD,YAAU,QAAQ,MAAM,UAAU,CAAC;AACnC,YAAU,KAAK,MAAM,UAAU;AAC/B,YAAU,KAAK,MAAM,UAAU;AAC/B,YAAU,KAAK,MAAM,UAAU,CAAC;AAChC,YAAU,OAAO,MAAM,UAAU,CAAC;AAClC,YAAU,SAAS,MAAM,UAAU,CAAC;AACpC,YAAU,KAAK,MAAM,UAAU,CAAC;AAEhC,wBAAsB,UAAU,QAAQ;AAAA,IACtC,QAAQ;AACN,UAAI,aAAa,MAAM;AACvB,UAAI,KAAK,WAAW;AAClB,sBAAc;AAAA;AAEhB,UAAI,KAAK,WAAW;AAClB,sBAAc;AAAA;AAEhB,aAAO;AAAA;AAAA;AAIX,qBAAmB,UAAU,KAAK;AAAA,IAChC,QAAQ;AACN,aAAO,KAAK,UAAU,YAAY,KAAK,aAAa;AAAA;AAAA,IAEtD,WAAW,MAAM,SAAS;AACxB,UAAI,CAAC,OAAO,SAAS,OAAO;AAC1B,eAAO,KAAK,eAAe,MAAM;AAAA;AAGnC,aAAO,KAAK,OAAO;AAAA;AAAA,WAEd,MAAM,OAAO,SAAS;AAC3B,cAAQ,MAAM;AACd,UAAI,UAAU,MAAM;AAClB,eAAO;AAAA;AAET,UAAI,SAAS,GAAG,KAAK,QAAQ,WAAW;AACtC,gBAAQ,SAAS,GAAG,OAAO,QAAQ,UAAU;AAAA,aAE1C;AACH,gBAAQ,IAAI,KAAK,GAAG,SAAS,QAAQ;AAAA;AAEvC,aAAO;AAAA;AAAA;AAIX,yBAAuB,UAAU,SAAS;AAAA,WACjC,MAAM,OAAO;AAClB,aAAO,MAAM;AAAA;AAAA;AAIjB,qBAAmB,UAAU,KAAK;AAAA,IAChC,QAAQ;AACN,aAAO;AAAA;AAAA;AAIX,yBAAuB,UAAU,SAAS;AAAA,IACxC,YAAY,MAAM,MAAM;AACtB,YAAM,MAAM;AACZ,UAAI,EAAE,QAAQ,KAAK,OAAO;AACxB,aAAK,UAAU,KAAK;AAAA,aAEjB;AACH,aAAK,UAAU,KAAK;AAAA;AAAA;AAAA,WAGjB,MAAM,OAAO;AAClB,cAAQ,MAAM;AAGd,UAAI,CAAC,SAAS,MAAM,WAAW,GAAG;AAChC,eAAO;AAAA;AAGT,cAAQ,MAAM,MAAM;AACpB,aAAO,IAAI,SAAS,MAAM,OAAO,UAAU,EAAE,UAAU;AAAA;AAAA,IAEzD,QAAQ;AACN,aAAO,KAAK;AAAA;AAAA;AAIhB,qBAAmB,UAAU,KAAK;AAAA,IAChC,MAAM,SAAS;AACb,aAAO,QAAQ,KAAK,OAAO,IAAI,WAAS,QAAQ,OAAO,QAAQ,KAAK;AAAA;AAAA;AAIxE,yBAAuB,UAAU,KAAK;AAAA,IACpC,WAAW,OAAO,SAAS;AACzB,aAAO,QAAQ,cAAc,WAAW,OAAO,UAAU,WAAW,QAChE,KAAK,UAAU;AAAA;AAAA;AAIvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA;AAAA;",
 | 
			
		||||
  "names": []
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										62
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
const AbstractDialect = require("../abstract");
 | 
			
		||||
const ConnectionManager = require("./connection-manager");
 | 
			
		||||
const Query = require("./query");
 | 
			
		||||
const QueryGenerator = require("./query-generator");
 | 
			
		||||
const { MySQLQueryInterface } = require("../mysql/query-interface");
 | 
			
		||||
const DataTypes = require("../../data-types").mariadb;
 | 
			
		||||
class MariadbDialect extends AbstractDialect {
 | 
			
		||||
  constructor(sequelize) {
 | 
			
		||||
    super();
 | 
			
		||||
    this.sequelize = sequelize;
 | 
			
		||||
    this.connectionManager = new ConnectionManager(this, sequelize);
 | 
			
		||||
    this.queryGenerator = new QueryGenerator({
 | 
			
		||||
      _dialect: this,
 | 
			
		||||
      sequelize
 | 
			
		||||
    });
 | 
			
		||||
    this.queryInterface = new MySQLQueryInterface(sequelize, this.queryGenerator);
 | 
			
		||||
  }
 | 
			
		||||
  canBackslashEscape() {
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
MariadbDialect.prototype.supports = _.merge(_.cloneDeep(AbstractDialect.prototype.supports), {
 | 
			
		||||
  "VALUES ()": true,
 | 
			
		||||
  "LIMIT ON UPDATE": true,
 | 
			
		||||
  lock: true,
 | 
			
		||||
  forShare: "LOCK IN SHARE MODE",
 | 
			
		||||
  settingIsolationLevelDuringTransaction: false,
 | 
			
		||||
  schemas: true,
 | 
			
		||||
  inserts: {
 | 
			
		||||
    ignoreDuplicates: " IGNORE",
 | 
			
		||||
    updateOnDuplicate: " ON DUPLICATE KEY UPDATE"
 | 
			
		||||
  },
 | 
			
		||||
  index: {
 | 
			
		||||
    collate: false,
 | 
			
		||||
    length: true,
 | 
			
		||||
    parser: true,
 | 
			
		||||
    type: true,
 | 
			
		||||
    using: 1
 | 
			
		||||
  },
 | 
			
		||||
  constraints: {
 | 
			
		||||
    dropConstraint: false,
 | 
			
		||||
    check: false
 | 
			
		||||
  },
 | 
			
		||||
  indexViaAlter: true,
 | 
			
		||||
  indexHints: true,
 | 
			
		||||
  NUMERIC: true,
 | 
			
		||||
  GEOMETRY: true,
 | 
			
		||||
  JSON: true,
 | 
			
		||||
  REGEXP: true
 | 
			
		||||
});
 | 
			
		||||
MariadbDialect.prototype.defaultVersion = "10.1.44";
 | 
			
		||||
MariadbDialect.prototype.Query = Query;
 | 
			
		||||
MariadbDialect.prototype.QueryGenerator = QueryGenerator;
 | 
			
		||||
MariadbDialect.prototype.DataTypes = DataTypes;
 | 
			
		||||
MariadbDialect.prototype.name = "mariadb";
 | 
			
		||||
MariadbDialect.prototype.TICK_CHAR = "`";
 | 
			
		||||
MariadbDialect.prototype.TICK_CHAR_LEFT = MariadbDialect.prototype.TICK_CHAR;
 | 
			
		||||
MariadbDialect.prototype.TICK_CHAR_RIGHT = MariadbDialect.prototype.TICK_CHAR;
 | 
			
		||||
module.exports = MariadbDialect;
 | 
			
		||||
//# sourceMappingURL=index.js.map
 | 
			
		||||
							
								
								
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/index.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/index.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
  "version": 3,
 | 
			
		||||
  "sources": ["../../../src/dialects/mariadb/index.js"],
 | 
			
		||||
  "sourcesContent": ["'use strict';\n\nconst _ = require('lodash');\nconst AbstractDialect = require('../abstract');\nconst ConnectionManager = require('./connection-manager');\nconst Query = require('./query');\nconst QueryGenerator = require('./query-generator');\nconst { MySQLQueryInterface } = require('../mysql/query-interface');\nconst DataTypes = require('../../data-types').mariadb;\n\nclass MariadbDialect extends AbstractDialect {\n  constructor(sequelize) {\n    super();\n    this.sequelize = sequelize;\n    this.connectionManager = new ConnectionManager(this, sequelize);\n    this.queryGenerator = new QueryGenerator({\n      _dialect: this,\n      sequelize\n    });\n    this.queryInterface = new MySQLQueryInterface(\n      sequelize,\n      this.queryGenerator\n    );\n  }\n\n  canBackslashEscape() {\n    return true;\n  }\n}\n\nMariadbDialect.prototype.supports = _.merge(\n  _.cloneDeep(AbstractDialect.prototype.supports),\n  {\n    'VALUES ()': true,\n    'LIMIT ON UPDATE': true,\n    lock: true,\n    forShare: 'LOCK IN SHARE MODE',\n    settingIsolationLevelDuringTransaction: false,\n    schemas: true,\n    inserts: {\n      ignoreDuplicates: ' IGNORE',\n      updateOnDuplicate: ' ON DUPLICATE KEY UPDATE'\n    },\n    index: {\n      collate: false,\n      length: true,\n      parser: true,\n      type: true,\n      using: 1\n    },\n    constraints: {\n      dropConstraint: false,\n      check: false\n    },\n    indexViaAlter: true,\n    indexHints: true,\n    NUMERIC: true,\n    GEOMETRY: true,\n    JSON: true,\n    REGEXP: true\n  }\n);\n\nMariadbDialect.prototype.defaultVersion = '10.1.44'; // minimum supported version\nMariadbDialect.prototype.Query = Query;\nMariadbDialect.prototype.QueryGenerator = QueryGenerator;\nMariadbDialect.prototype.DataTypes = DataTypes;\nMariadbDialect.prototype.name = 'mariadb';\nMariadbDialect.prototype.TICK_CHAR = '`';\nMariadbDialect.prototype.TICK_CHAR_LEFT = MariadbDialect.prototype.TICK_CHAR;\nMariadbDialect.prototype.TICK_CHAR_RIGHT = MariadbDialect.prototype.TICK_CHAR;\n\nmodule.exports = MariadbDialect;\n"],
 | 
			
		||||
  "mappings": ";AAEA,MAAM,IAAI,QAAQ;AAClB,MAAM,kBAAkB,QAAQ;AAChC,MAAM,oBAAoB,QAAQ;AAClC,MAAM,QAAQ,QAAQ;AACtB,MAAM,iBAAiB,QAAQ;AAC/B,MAAM,EAAE,wBAAwB,QAAQ;AACxC,MAAM,YAAY,QAAQ,oBAAoB;AAE9C,6BAA6B,gBAAgB;AAAA,EAC3C,YAAY,WAAW;AACrB;AACA,SAAK,YAAY;AACjB,SAAK,oBAAoB,IAAI,kBAAkB,MAAM;AACrD,SAAK,iBAAiB,IAAI,eAAe;AAAA,MACvC,UAAU;AAAA,MACV;AAAA;AAEF,SAAK,iBAAiB,IAAI,oBACxB,WACA,KAAK;AAAA;AAAA,EAIT,qBAAqB;AACnB,WAAO;AAAA;AAAA;AAIX,eAAe,UAAU,WAAW,EAAE,MACpC,EAAE,UAAU,gBAAgB,UAAU,WACtC;AAAA,EACE,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,wCAAwC;AAAA,EACxC,SAAS;AAAA,EACT,SAAS;AAAA,IACP,kBAAkB;AAAA,IAClB,mBAAmB;AAAA;AAAA,EAErB,OAAO;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA;AAAA,EAET,aAAa;AAAA,IACX,gBAAgB;AAAA,IAChB,OAAO;AAAA;AAAA,EAET,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AAAA;AAIZ,eAAe,UAAU,iBAAiB;AAC1C,eAAe,UAAU,QAAQ;AACjC,eAAe,UAAU,iBAAiB;AAC1C,eAAe,UAAU,YAAY;AACrC,eAAe,UAAU,OAAO;AAChC,eAAe,UAAU,YAAY;AACrC,eAAe,UAAU,iBAAiB,eAAe,UAAU;AACnE,eAAe,UAAU,kBAAkB,eAAe,UAAU;AAEpE,OAAO,UAAU;",
 | 
			
		||||
  "names": []
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										69
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/query-generator.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/query-generator.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,69 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
var __defProp = Object.defineProperty;
 | 
			
		||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
 | 
			
		||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
 | 
			
		||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
 | 
			
		||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
 | 
			
		||||
var __spreadValues = (a, b) => {
 | 
			
		||||
  for (var prop in b || (b = {}))
 | 
			
		||||
    if (__hasOwnProp.call(b, prop))
 | 
			
		||||
      __defNormalProp(a, prop, b[prop]);
 | 
			
		||||
  if (__getOwnPropSymbols)
 | 
			
		||||
    for (var prop of __getOwnPropSymbols(b)) {
 | 
			
		||||
      if (__propIsEnum.call(b, prop))
 | 
			
		||||
        __defNormalProp(a, prop, b[prop]);
 | 
			
		||||
    }
 | 
			
		||||
  return a;
 | 
			
		||||
};
 | 
			
		||||
const MySQLQueryGenerator = require("../mysql/query-generator");
 | 
			
		||||
const Utils = require("./../../utils");
 | 
			
		||||
class MariaDBQueryGenerator extends MySQLQueryGenerator {
 | 
			
		||||
  createSchema(schema, options) {
 | 
			
		||||
    options = __spreadValues({
 | 
			
		||||
      charset: null,
 | 
			
		||||
      collate: null
 | 
			
		||||
    }, options);
 | 
			
		||||
    return Utils.joinSQLFragments([
 | 
			
		||||
      "CREATE SCHEMA IF NOT EXISTS",
 | 
			
		||||
      this.quoteIdentifier(schema),
 | 
			
		||||
      options.charset && `DEFAULT CHARACTER SET ${this.escape(options.charset)}`,
 | 
			
		||||
      options.collate && `DEFAULT COLLATE ${this.escape(options.collate)}`,
 | 
			
		||||
      ";"
 | 
			
		||||
    ]);
 | 
			
		||||
  }
 | 
			
		||||
  dropSchema(schema) {
 | 
			
		||||
    return `DROP SCHEMA IF EXISTS ${this.quoteIdentifier(schema)};`;
 | 
			
		||||
  }
 | 
			
		||||
  showSchemasQuery(options) {
 | 
			
		||||
    const schemasToSkip = [
 | 
			
		||||
      "'MYSQL'",
 | 
			
		||||
      "'INFORMATION_SCHEMA'",
 | 
			
		||||
      "'PERFORMANCE_SCHEMA'"
 | 
			
		||||
    ];
 | 
			
		||||
    if (options.skip && Array.isArray(options.skip) && options.skip.length > 0) {
 | 
			
		||||
      for (const schemaName of options.skip) {
 | 
			
		||||
        schemasToSkip.push(this.escape(schemaName));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return Utils.joinSQLFragments([
 | 
			
		||||
      "SELECT SCHEMA_NAME as schema_name",
 | 
			
		||||
      "FROM INFORMATION_SCHEMA.SCHEMATA",
 | 
			
		||||
      `WHERE SCHEMA_NAME NOT IN (${schemasToSkip.join(", ")})`,
 | 
			
		||||
      ";"
 | 
			
		||||
    ]);
 | 
			
		||||
  }
 | 
			
		||||
  showTablesQuery(database) {
 | 
			
		||||
    let query = "SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'";
 | 
			
		||||
    if (database) {
 | 
			
		||||
      query += ` AND TABLE_SCHEMA = ${this.escape(database)}`;
 | 
			
		||||
    } else {
 | 
			
		||||
      query += " AND TABLE_SCHEMA NOT IN ('MYSQL', 'INFORMATION_SCHEMA', 'PERFORMANCE_SCHEMA')";
 | 
			
		||||
    }
 | 
			
		||||
    return `${query};`;
 | 
			
		||||
  }
 | 
			
		||||
  quoteIdentifier(identifier, force) {
 | 
			
		||||
    return Utils.addTicks(Utils.removeTicks(identifier, "`"), "`");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
module.exports = MariaDBQueryGenerator;
 | 
			
		||||
//# sourceMappingURL=query-generator.js.map
 | 
			
		||||
							
								
								
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/query-generator.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/query-generator.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
  "version": 3,
 | 
			
		||||
  "sources": ["../../../src/dialects/mariadb/query-generator.js"],
 | 
			
		||||
  "sourcesContent": ["'use strict';\n\nconst MySQLQueryGenerator = require('../mysql/query-generator');\nconst Utils = require('./../../utils');\n\nclass MariaDBQueryGenerator extends MySQLQueryGenerator {\n  createSchema(schema, options) {\n    options = {\n      charset: null,\n      collate: null,\n      ...options\n    };\n\n    return Utils.joinSQLFragments([\n      'CREATE SCHEMA IF NOT EXISTS',\n      this.quoteIdentifier(schema),\n      options.charset && `DEFAULT CHARACTER SET ${this.escape(options.charset)}`,\n      options.collate && `DEFAULT COLLATE ${this.escape(options.collate)}`,\n      ';'\n    ]);\n  }\n\n  dropSchema(schema) {\n    return `DROP SCHEMA IF EXISTS ${this.quoteIdentifier(schema)};`;\n  }\n\n  showSchemasQuery(options) {\n    const schemasToSkip = [\n      '\\'MYSQL\\'',\n      '\\'INFORMATION_SCHEMA\\'',\n      '\\'PERFORMANCE_SCHEMA\\''\n    ];\n    if (options.skip && Array.isArray(options.skip) && options.skip.length > 0) {\n      for (const schemaName of options.skip) {\n        schemasToSkip.push(this.escape(schemaName));\n      }\n    }\n    return Utils.joinSQLFragments([\n      'SELECT SCHEMA_NAME as schema_name',\n      'FROM INFORMATION_SCHEMA.SCHEMATA',\n      `WHERE SCHEMA_NAME NOT IN (${schemasToSkip.join(', ')})`,\n      ';'\n    ]);\n  }\n\n  showTablesQuery(database) {\n    let query = 'SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = \\'BASE TABLE\\'';\n    if (database) {\n      query += ` AND TABLE_SCHEMA = ${this.escape(database)}`;\n    } else {\n      query += ' AND TABLE_SCHEMA NOT IN (\\'MYSQL\\', \\'INFORMATION_SCHEMA\\', \\'PERFORMANCE_SCHEMA\\')';\n    }\n    return `${query};`;\n  }\n\n  /**\n   * Quote identifier in sql clause\n   *\n   * @param {string} identifier\n   * @param {boolean} force\n   *\n   * @returns {string}\n   */\n  quoteIdentifier(identifier, force) {\n    return Utils.addTicks(Utils.removeTicks(identifier, '`'), '`');\n  }\n}\n\nmodule.exports = MariaDBQueryGenerator;\n"],
 | 
			
		||||
  "mappings": ";;;;;;;;;;;;;;;;;AAEA,MAAM,sBAAsB,QAAQ;AACpC,MAAM,QAAQ,QAAQ;AAEtB,oCAAoC,oBAAoB;AAAA,EACtD,aAAa,QAAQ,SAAS;AAC5B,cAAU;AAAA,MACR,SAAS;AAAA,MACT,SAAS;AAAA,OACN;AAGL,WAAO,MAAM,iBAAiB;AAAA,MAC5B;AAAA,MACA,KAAK,gBAAgB;AAAA,MACrB,QAAQ,WAAW,yBAAyB,KAAK,OAAO,QAAQ;AAAA,MAChE,QAAQ,WAAW,mBAAmB,KAAK,OAAO,QAAQ;AAAA,MAC1D;AAAA;AAAA;AAAA,EAIJ,WAAW,QAAQ;AACjB,WAAO,yBAAyB,KAAK,gBAAgB;AAAA;AAAA,EAGvD,iBAAiB,SAAS;AACxB,UAAM,gBAAgB;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA;AAEF,QAAI,QAAQ,QAAQ,MAAM,QAAQ,QAAQ,SAAS,QAAQ,KAAK,SAAS,GAAG;AAC1E,iBAAW,cAAc,QAAQ,MAAM;AACrC,sBAAc,KAAK,KAAK,OAAO;AAAA;AAAA;AAGnC,WAAO,MAAM,iBAAiB;AAAA,MAC5B;AAAA,MACA;AAAA,MACA,6BAA6B,cAAc,KAAK;AAAA,MAChD;AAAA;AAAA;AAAA,EAIJ,gBAAgB,UAAU;AACxB,QAAI,QAAQ;AACZ,QAAI,UAAU;AACZ,eAAS,uBAAuB,KAAK,OAAO;AAAA,WACvC;AACL,eAAS;AAAA;AAEX,WAAO,GAAG;AAAA;AAAA,EAWZ,gBAAgB,YAAY,OAAO;AACjC,WAAO,MAAM,SAAS,MAAM,YAAY,YAAY,MAAM;AAAA;AAAA;AAI9D,OAAO,UAAU;",
 | 
			
		||||
  "names": []
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										254
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/query.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										254
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/query.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,254 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
var __defProp = Object.defineProperty;
 | 
			
		||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
 | 
			
		||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
 | 
			
		||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
 | 
			
		||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
 | 
			
		||||
var __spreadValues = (a, b) => {
 | 
			
		||||
  for (var prop in b || (b = {}))
 | 
			
		||||
    if (__hasOwnProp.call(b, prop))
 | 
			
		||||
      __defNormalProp(a, prop, b[prop]);
 | 
			
		||||
  if (__getOwnPropSymbols)
 | 
			
		||||
    for (var prop of __getOwnPropSymbols(b)) {
 | 
			
		||||
      if (__propIsEnum.call(b, prop))
 | 
			
		||||
        __defNormalProp(a, prop, b[prop]);
 | 
			
		||||
    }
 | 
			
		||||
  return a;
 | 
			
		||||
};
 | 
			
		||||
const AbstractQuery = require("../abstract/query");
 | 
			
		||||
const sequelizeErrors = require("../../errors");
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
const DataTypes = require("../../data-types");
 | 
			
		||||
const { logger } = require("../../utils/logger");
 | 
			
		||||
const ER_DUP_ENTRY = 1062;
 | 
			
		||||
const ER_DEADLOCK = 1213;
 | 
			
		||||
const ER_ROW_IS_REFERENCED = 1451;
 | 
			
		||||
const ER_NO_REFERENCED_ROW = 1452;
 | 
			
		||||
const debug = logger.debugContext("sql:mariadb");
 | 
			
		||||
class Query extends AbstractQuery {
 | 
			
		||||
  constructor(connection, sequelize, options) {
 | 
			
		||||
    super(connection, sequelize, __spreadValues({ showWarnings: false }, options));
 | 
			
		||||
  }
 | 
			
		||||
  static formatBindParameters(sql, values, dialect) {
 | 
			
		||||
    const bindParam = [];
 | 
			
		||||
    const replacementFunc = (match, key, values_) => {
 | 
			
		||||
      if (values_[key] !== void 0) {
 | 
			
		||||
        bindParam.push(values_[key]);
 | 
			
		||||
        return "?";
 | 
			
		||||
      }
 | 
			
		||||
      return void 0;
 | 
			
		||||
    };
 | 
			
		||||
    sql = AbstractQuery.formatBindParameters(sql, values, dialect, replacementFunc)[0];
 | 
			
		||||
    return [sql, bindParam.length > 0 ? bindParam : void 0];
 | 
			
		||||
  }
 | 
			
		||||
  async run(sql, parameters) {
 | 
			
		||||
    this.sql = sql;
 | 
			
		||||
    const { connection, options } = this;
 | 
			
		||||
    const showWarnings = this.sequelize.options.showWarnings || options.showWarnings;
 | 
			
		||||
    const complete = this._logQuery(sql, debug, parameters);
 | 
			
		||||
    if (parameters) {
 | 
			
		||||
      debug("parameters(%j)", parameters);
 | 
			
		||||
    }
 | 
			
		||||
    let results;
 | 
			
		||||
    const errForStack = new Error();
 | 
			
		||||
    try {
 | 
			
		||||
      results = await connection.query(this.sql, parameters);
 | 
			
		||||
    } catch (error) {
 | 
			
		||||
      if (options.transaction && error.errno === ER_DEADLOCK) {
 | 
			
		||||
        try {
 | 
			
		||||
          await options.transaction.rollback();
 | 
			
		||||
        } catch (error_) {
 | 
			
		||||
        }
 | 
			
		||||
        options.transaction.finished = "rollback";
 | 
			
		||||
      }
 | 
			
		||||
      error.sql = sql;
 | 
			
		||||
      error.parameters = parameters;
 | 
			
		||||
      throw this.formatError(error, errForStack.stack);
 | 
			
		||||
    } finally {
 | 
			
		||||
      complete();
 | 
			
		||||
    }
 | 
			
		||||
    if (showWarnings && results && results.warningStatus > 0) {
 | 
			
		||||
      await this.logWarnings(results);
 | 
			
		||||
    }
 | 
			
		||||
    return this.formatResults(results);
 | 
			
		||||
  }
 | 
			
		||||
  formatResults(data) {
 | 
			
		||||
    let result = this.instance;
 | 
			
		||||
    if (this.isBulkUpdateQuery() || this.isBulkDeleteQuery()) {
 | 
			
		||||
      return data.affectedRows;
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isUpsertQuery()) {
 | 
			
		||||
      return [result, data.affectedRows === 1];
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isInsertQuery(data)) {
 | 
			
		||||
      this.handleInsertQuery(data);
 | 
			
		||||
      if (!this.instance) {
 | 
			
		||||
        if (this.model && this.model.autoIncrementAttribute && this.model.autoIncrementAttribute === this.model.primaryKeyAttribute && this.model.rawAttributes[this.model.primaryKeyAttribute]) {
 | 
			
		||||
          const startId = data[this.getInsertIdField()];
 | 
			
		||||
          result = new Array(data.affectedRows);
 | 
			
		||||
          const pkField = this.model.rawAttributes[this.model.primaryKeyAttribute].field;
 | 
			
		||||
          for (let i = 0; i < data.affectedRows; i++) {
 | 
			
		||||
            result[i] = { [pkField]: startId + i };
 | 
			
		||||
          }
 | 
			
		||||
          return [result, data.affectedRows];
 | 
			
		||||
        }
 | 
			
		||||
        return [data[this.getInsertIdField()], data.affectedRows];
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isSelectQuery()) {
 | 
			
		||||
      this.handleJsonSelectQuery(data);
 | 
			
		||||
      return this.handleSelectQuery(data);
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isInsertQuery() || this.isUpdateQuery()) {
 | 
			
		||||
      return [result, data.affectedRows];
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isCallQuery()) {
 | 
			
		||||
      return data[0];
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isRawQuery()) {
 | 
			
		||||
      const meta = data.meta;
 | 
			
		||||
      delete data.meta;
 | 
			
		||||
      return [data, meta];
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isShowIndexesQuery()) {
 | 
			
		||||
      return this.handleShowIndexesQuery(data);
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isForeignKeysQuery() || this.isShowConstraintsQuery()) {
 | 
			
		||||
      return data;
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isShowTablesQuery()) {
 | 
			
		||||
      return this.handleShowTablesQuery(data);
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isDescribeQuery()) {
 | 
			
		||||
      result = {};
 | 
			
		||||
      for (const _result of data) {
 | 
			
		||||
        result[_result.Field] = {
 | 
			
		||||
          type: _result.Type.toLowerCase().startsWith("enum") ? _result.Type.replace(/^enum/i, "ENUM") : _result.Type.toUpperCase(),
 | 
			
		||||
          allowNull: _result.Null === "YES",
 | 
			
		||||
          defaultValue: _result.Default,
 | 
			
		||||
          primaryKey: _result.Key === "PRI",
 | 
			
		||||
          autoIncrement: Object.prototype.hasOwnProperty.call(_result, "Extra") && _result.Extra.toLowerCase() === "auto_increment",
 | 
			
		||||
          comment: _result.Comment ? _result.Comment : null
 | 
			
		||||
        };
 | 
			
		||||
      }
 | 
			
		||||
      return result;
 | 
			
		||||
    }
 | 
			
		||||
    if (this.isVersionQuery()) {
 | 
			
		||||
      return data[0].version;
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
  }
 | 
			
		||||
  handleJsonSelectQuery(rows) {
 | 
			
		||||
    if (!this.model || !this.model.fieldRawAttributesMap) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    for (const _field of Object.keys(this.model.fieldRawAttributesMap)) {
 | 
			
		||||
      const modelField = this.model.fieldRawAttributesMap[_field];
 | 
			
		||||
      if (modelField.type instanceof DataTypes.JSON) {
 | 
			
		||||
        rows = rows.map((row) => {
 | 
			
		||||
          if (row[modelField.fieldName] && typeof row[modelField.fieldName] === "string" && !this.connection.info.hasMinVersion(10, 5, 2)) {
 | 
			
		||||
            row[modelField.fieldName] = JSON.parse(row[modelField.fieldName]);
 | 
			
		||||
          }
 | 
			
		||||
          if (DataTypes.JSON.parse) {
 | 
			
		||||
            return DataTypes.JSON.parse(modelField, this.sequelize.options, row[modelField.fieldName]);
 | 
			
		||||
          }
 | 
			
		||||
          return row;
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  async logWarnings(results) {
 | 
			
		||||
    const warningResults = await this.run("SHOW WARNINGS");
 | 
			
		||||
    const warningMessage = `MariaDB Warnings (${this.connection.uuid || "default"}): `;
 | 
			
		||||
    const messages = [];
 | 
			
		||||
    for (const _warningRow of warningResults) {
 | 
			
		||||
      if (_warningRow === void 0 || typeof _warningRow[Symbol.iterator] !== "function") {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
      for (const _warningResult of _warningRow) {
 | 
			
		||||
        if (Object.prototype.hasOwnProperty.call(_warningResult, "Message")) {
 | 
			
		||||
          messages.push(_warningResult.Message);
 | 
			
		||||
        } else {
 | 
			
		||||
          for (const _objectKey of _warningResult.keys()) {
 | 
			
		||||
            messages.push([_objectKey, _warningResult[_objectKey]].join(": "));
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    this.sequelize.log(warningMessage + messages.join("; "), this.options);
 | 
			
		||||
    return results;
 | 
			
		||||
  }
 | 
			
		||||
  formatError(err, errStack) {
 | 
			
		||||
    switch (err.errno) {
 | 
			
		||||
      case ER_DUP_ENTRY: {
 | 
			
		||||
        const match = err.message.match(/Duplicate entry '([\s\S]*)' for key '?((.|\s)*?)'?\s.*$/);
 | 
			
		||||
        let fields = {};
 | 
			
		||||
        let message = "Validation error";
 | 
			
		||||
        const values = match ? match[1].split("-") : void 0;
 | 
			
		||||
        const fieldKey = match ? match[2] : void 0;
 | 
			
		||||
        const fieldVal = match ? match[1] : void 0;
 | 
			
		||||
        const uniqueKey = this.model && this.model.uniqueKeys[fieldKey];
 | 
			
		||||
        if (uniqueKey) {
 | 
			
		||||
          if (uniqueKey.msg)
 | 
			
		||||
            message = uniqueKey.msg;
 | 
			
		||||
          fields = _.zipObject(uniqueKey.fields, values);
 | 
			
		||||
        } else {
 | 
			
		||||
          fields[fieldKey] = fieldVal;
 | 
			
		||||
        }
 | 
			
		||||
        const errors = [];
 | 
			
		||||
        _.forOwn(fields, (value, field) => {
 | 
			
		||||
          errors.push(new sequelizeErrors.ValidationErrorItem(this.getUniqueConstraintErrorMessage(field), "unique violation", field, value, this.instance, "not_unique"));
 | 
			
		||||
        });
 | 
			
		||||
        return new sequelizeErrors.UniqueConstraintError({ message, errors, parent: err, fields, stack: errStack });
 | 
			
		||||
      }
 | 
			
		||||
      case ER_ROW_IS_REFERENCED:
 | 
			
		||||
      case ER_NO_REFERENCED_ROW: {
 | 
			
		||||
        const match = err.message.match(/CONSTRAINT ([`"])(.*)\1 FOREIGN KEY \(\1(.*)\1\) REFERENCES \1(.*)\1 \(\1(.*)\1\)/);
 | 
			
		||||
        const quoteChar = match ? match[1] : "`";
 | 
			
		||||
        const fields = match ? match[3].split(new RegExp(`${quoteChar}, *${quoteChar}`)) : void 0;
 | 
			
		||||
        return new sequelizeErrors.ForeignKeyConstraintError({
 | 
			
		||||
          reltype: err.errno === ER_ROW_IS_REFERENCED ? "parent" : "child",
 | 
			
		||||
          table: match ? match[4] : void 0,
 | 
			
		||||
          fields,
 | 
			
		||||
          value: fields && fields.length && this.instance && this.instance[fields[0]] || void 0,
 | 
			
		||||
          index: match ? match[2] : void 0,
 | 
			
		||||
          parent: err,
 | 
			
		||||
          stack: errStack
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
      default:
 | 
			
		||||
        return new sequelizeErrors.DatabaseError(err, { stack: errStack });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  handleShowTablesQuery(results) {
 | 
			
		||||
    return results.map((resultSet) => ({
 | 
			
		||||
      tableName: resultSet.TABLE_NAME,
 | 
			
		||||
      schema: resultSet.TABLE_SCHEMA
 | 
			
		||||
    }));
 | 
			
		||||
  }
 | 
			
		||||
  handleShowIndexesQuery(data) {
 | 
			
		||||
    let currItem;
 | 
			
		||||
    const result = [];
 | 
			
		||||
    data.forEach((item) => {
 | 
			
		||||
      if (!currItem || currItem.name !== item.Key_name) {
 | 
			
		||||
        currItem = {
 | 
			
		||||
          primary: item.Key_name === "PRIMARY",
 | 
			
		||||
          fields: [],
 | 
			
		||||
          name: item.Key_name,
 | 
			
		||||
          tableName: item.Table,
 | 
			
		||||
          unique: item.Non_unique !== 1,
 | 
			
		||||
          type: item.Index_type
 | 
			
		||||
        };
 | 
			
		||||
        result.push(currItem);
 | 
			
		||||
      }
 | 
			
		||||
      currItem.fields[item.Seq_in_index - 1] = {
 | 
			
		||||
        attribute: item.Column_name,
 | 
			
		||||
        length: item.Sub_part || void 0,
 | 
			
		||||
        order: item.Collation === "A" ? "ASC" : void 0
 | 
			
		||||
      };
 | 
			
		||||
    });
 | 
			
		||||
    return result;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
module.exports = Query;
 | 
			
		||||
//# sourceMappingURL=query.js.map
 | 
			
		||||
							
								
								
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/query.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								qwen/nodejs/node_modules/sequelize/lib/dialects/mariadb/query.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user