index.js 1.6 KB

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