API Reference Source

lib/dialects/postgres/index.js

  1. 'use strict';
  2.  
  3. const _ = require('lodash');
  4. const AbstractDialect = require('../abstract');
  5. const ConnectionManager = require('./connection-manager');
  6. const Query = require('./query');
  7. const QueryGenerator = require('./query-generator');
  8. const DataTypes = require('../../data-types').postgres;
  9.  
  10. class PostgresDialect extends AbstractDialect {
  11. constructor(sequelize) {
  12. super();
  13. this.sequelize = sequelize;
  14. this.connectionManager = new ConnectionManager(this, sequelize);
  15. this.QueryGenerator = new QueryGenerator({
  16. _dialect: this,
  17. sequelize
  18. });
  19. }
  20. }
  21.  
  22. PostgresDialect.prototype.supports = _.merge(_.cloneDeep(AbstractDialect.prototype.supports), {
  23. 'DEFAULT VALUES': true,
  24. 'EXCEPTION': true,
  25. 'ON DUPLICATE KEY': false,
  26. 'ORDER NULLS': true,
  27. returnValues: {
  28. returning: true
  29. },
  30. bulkDefault: true,
  31. schemas: true,
  32. lock: true,
  33. lockOf: true,
  34. lockKey: true,
  35. lockOuterJoinFailure: true,
  36. skipLocked: true,
  37. forShare: 'FOR SHARE',
  38. index: {
  39. concurrently: true,
  40. using: 2,
  41. where: true,
  42. functionBased: 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.  
  61. ConnectionManager.prototype.defaultVersion = '9.4.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.  
  69. module.exports = PostgresDialect;
  70. module.exports.default = PostgresDialect;
  71. module.exports.PostgresDialect = PostgresDialect;