API Reference Source

lib/dialects/mysql/index.js

  1. 'use strict';
  2.  
  3. const _ = require('lodash');
  4. const AbstractDialect = require('../abstract');
  5. const ConnectionManager = require('./connection-manager');
  6. const Query = require('./query');
  7. const QueryGenerator = require('./query-generator');
  8. const DataTypes = require('../../data-types').mysql;
  9.  
  10. class MysqlDialect extends AbstractDialect {
  11. constructor(sequelize) {
  12. super();
  13. this.sequelize = sequelize;
  14. this.connectionManager = new ConnectionManager(this, sequelize);
  15. this.QueryGenerator = new QueryGenerator({
  16. _dialect: this,
  17. sequelize
  18. });
  19. }
  20. }
  21.  
  22. MysqlDialect.prototype.supports = _.merge(_.cloneDeep(AbstractDialect.prototype.supports), {
  23. 'VALUES ()': true,
  24. 'LIMIT ON UPDATE': true,
  25. lock: true,
  26. forShare: 'LOCK IN SHARE MODE',
  27. settingIsolationLevelDuringTransaction: false,
  28. inserts: {
  29. ignoreDuplicates: ' IGNORE',
  30. updateOnDuplicate: ' ON DUPLICATE KEY UPDATE'
  31. },
  32. index: {
  33. collate: false,
  34. length: true,
  35. parser: true,
  36. type: true,
  37. using: 1
  38. },
  39. constraints: {
  40. dropConstraint: false,
  41. check: false
  42. },
  43. indexViaAlter: true,
  44. indexHints: true,
  45. NUMERIC: true,
  46. GEOMETRY: true,
  47. JSON: true,
  48. REGEXP: true
  49. });
  50.  
  51. ConnectionManager.prototype.defaultVersion = '5.6.0';
  52. MysqlDialect.prototype.Query = Query;
  53. MysqlDialect.prototype.QueryGenerator = QueryGenerator;
  54. MysqlDialect.prototype.DataTypes = DataTypes;
  55. MysqlDialect.prototype.name = 'mysql';
  56. MysqlDialect.prototype.TICK_CHAR = '`';
  57. MysqlDialect.prototype.TICK_CHAR_LEFT = MysqlDialect.prototype.TICK_CHAR;
  58. MysqlDialect.prototype.TICK_CHAR_RIGHT = MysqlDialect.prototype.TICK_CHAR;
  59.  
  60. module.exports = MysqlDialect;