index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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').postgres;
  8. class PostgresDialect 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. PostgresDialect.prototype.supports = _.merge(_.cloneDeep(AbstractDialect.prototype.supports), {
  20. 'DEFAULT VALUES': true,
  21. 'EXCEPTION': true,
  22. 'ON DUPLICATE KEY': false,
  23. 'ORDER NULLS': true,
  24. returnValues: {
  25. returning: true
  26. },
  27. bulkDefault: true,
  28. schemas: true,
  29. lock: true,
  30. lockOf: true,
  31. lockKey: true,
  32. lockOuterJoinFailure: true,
  33. skipLocked: true,
  34. forShare: 'FOR SHARE',
  35. index: {
  36. concurrently: true,
  37. using: 2,
  38. where: true,
  39. functionBased: true
  40. },
  41. inserts: {
  42. onConflictDoNothing: ' ON CONFLICT DO NOTHING',
  43. updateOnDuplicate: ' ON CONFLICT DO UPDATE SET'
  44. },
  45. NUMERIC: true,
  46. ARRAY: true,
  47. RANGE: true,
  48. GEOMETRY: true,
  49. REGEXP: true,
  50. GEOGRAPHY: true,
  51. JSON: true,
  52. JSONB: true,
  53. HSTORE: true,
  54. deferrableConstraints: true,
  55. searchPath: true
  56. });
  57. ConnectionManager.prototype.defaultVersion = '9.4.0';
  58. PostgresDialect.prototype.Query = Query;
  59. PostgresDialect.prototype.DataTypes = DataTypes;
  60. PostgresDialect.prototype.name = 'postgres';
  61. PostgresDialect.prototype.TICK_CHAR = '"';
  62. PostgresDialect.prototype.TICK_CHAR_LEFT = PostgresDialect.prototype.TICK_CHAR;
  63. PostgresDialect.prototype.TICK_CHAR_RIGHT = PostgresDialect.prototype.TICK_CHAR;
  64. module.exports = PostgresDialect;
  65. module.exports.default = PostgresDialect;
  66. module.exports.PostgresDialect = PostgresDialect;