columncompiler.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _assign2 = require('lodash/assign');
  4. var _assign3 = _interopRequireDefault(_assign2);
  5. var _inherits = require('inherits');
  6. var _inherits2 = _interopRequireDefault(_inherits);
  7. var _columncompiler = require('../../postgres/schema/columncompiler');
  8. var _columncompiler2 = _interopRequireDefault(_columncompiler);
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. // Redshift Column Compiler
  11. // -------
  12. function ColumnCompiler_Redshift() {
  13. _columncompiler2.default.apply(this, arguments);
  14. }
  15. (0, _inherits2.default)(ColumnCompiler_Redshift, _columncompiler2.default);
  16. (0, _assign3.default)(ColumnCompiler_Redshift.prototype, {
  17. // Types:
  18. // ------
  19. bigincrements: 'bigint identity(1,1) primary key not null',
  20. binary: 'varchar(max)',
  21. bit: function bit(column) {
  22. return column.length !== false ? 'char(' + column.length + ')' : 'char(1)';
  23. },
  24. blob: 'varchar(max)',
  25. enu: 'varchar(255)',
  26. enum: 'varchar(255)',
  27. increments: 'integer identity(1,1) primary key not null',
  28. json: 'varchar(max)',
  29. jsonb: 'varchar(max)',
  30. longblob: 'varchar(max)',
  31. mediumblob: 'varchar(16777218)',
  32. set: 'text',
  33. text: 'varchar(max)',
  34. datetime: function datetime(without) {
  35. return without ? 'timestamp' : 'timestamptz';
  36. },
  37. timestamp: function timestamp(without) {
  38. return without ? 'timestamp' : 'timestamptz';
  39. },
  40. tinyblob: 'varchar(256)',
  41. uuid: 'char(36)',
  42. varbinary: 'varchar(max)',
  43. bigint: 'bigint',
  44. bool: 'boolean',
  45. double: 'double precision',
  46. floating: 'real',
  47. smallint: 'smallint',
  48. tinyint: 'smallint',
  49. // Modifiers:
  50. // ------
  51. comment: function comment(_comment) {
  52. this.pushAdditional(function () {
  53. this.pushQuery('comment on column ' + this.tableCompiler.tableName() + '.' + this.formatter.wrap(this.args[0]) + " is " + (_comment ? '\'' + _comment + '\'' : 'NULL'));
  54. }, _comment);
  55. }
  56. });
  57. exports.default = ColumnCompiler_Redshift;
  58. module.exports = exports['default'];