index.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. deferrableConstraints: true,
  58. searchPath: true
  59. });
  60. PostgresDialect.prototype.defaultVersion = '9.5.0';
  61. PostgresDialect.prototype.Query = Query;
  62. PostgresDialect.prototype.DataTypes = DataTypes;
  63. PostgresDialect.prototype.name = 'postgres';
  64. PostgresDialect.prototype.TICK_CHAR = '"';
  65. PostgresDialect.prototype.TICK_CHAR_LEFT = PostgresDialect.prototype.TICK_CHAR;
  66. PostgresDialect.prototype.TICK_CHAR_RIGHT = PostgresDialect.prototype.TICK_CHAR;
  67. module.exports = PostgresDialect;
  68. module.exports.default = PostgresDialect;
  69. module.exports.PostgresDialect = PostgresDialect;