index.js 2.1 KB

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