index.js 1.7 KB

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