@mikro-orm/postgresql 6.3.5-dev.17 → 6.3.5-dev.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,6 +38,12 @@ export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
38
38
  getFullTextWhereClause(prop: EntityProperty): string;
39
39
  supportsCreatingFullTextIndex(): boolean;
40
40
  getFullTextIndexExpression(indexName: string, schemaName: string | undefined, tableName: string, columns: SimpleColumnMeta[]): string;
41
+ normalizeColumnType(type: string, options?: {
42
+ length?: number;
43
+ precision?: number;
44
+ scale?: number;
45
+ autoincrement?: boolean;
46
+ }): string;
41
47
  getMappedType(type: string): Type<unknown>;
42
48
  getRegExpOperator(val?: unknown, flags?: string): string;
43
49
  getRegExpValue(val: RegExp): {
@@ -62,6 +68,9 @@ export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
62
68
  getCharTypeDeclarationSQL(column: {
63
69
  length?: number;
64
70
  }): string;
71
+ getIntervalTypeDeclarationSQL(column: {
72
+ length?: number;
73
+ }): string;
65
74
  getBlobDeclarationSQL(): string;
66
75
  getJsonDeclarationSQL(): string;
67
76
  getSearchJsonPropertyKey(path: string[], type: string | undefined | Type, aliased: boolean, value?: unknown): string;
@@ -41,7 +41,7 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
41
41
  return 'timestamptz' + (column.length != null ? `(${column.length})` : '');
42
42
  }
43
43
  getDefaultDateTimeLength() {
44
- return 6; // timestamptz actually means timestamptz(6)
44
+ return 6;
45
45
  }
46
46
  convertIntervalToJSValue(value) {
47
47
  return (0, postgres_interval_1.default)(value);
@@ -57,9 +57,9 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
57
57
  }
58
58
  getIntegerTypeDeclarationSQL(column) {
59
59
  if (column.autoincrement && !column.generated) {
60
- return `serial`;
60
+ return 'serial';
61
61
  }
62
- return `int`;
62
+ return 'int';
63
63
  }
64
64
  getBigIntTypeDeclarationSQL(column) {
65
65
  /* istanbul ignore next */
@@ -97,6 +97,34 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
97
97
  }
98
98
  return `create index ${quotedIndexName} on ${quotedTableName} using gin(to_tsvector('simple', ${quotedColumnNames.join(` || ' ' || `)}))`;
99
99
  }
100
+ normalizeColumnType(type, options = {}) {
101
+ const simpleType = this.extractSimpleType(type);
102
+ if (['int', 'int4', 'integer'].includes(simpleType)) {
103
+ return this.getIntegerTypeDeclarationSQL({});
104
+ }
105
+ if (['bigint', 'int8'].includes(simpleType)) {
106
+ return this.getBigIntTypeDeclarationSQL({});
107
+ }
108
+ if (['smallint', 'int2'].includes(simpleType)) {
109
+ return this.getSmallIntTypeDeclarationSQL({});
110
+ }
111
+ if (['boolean', 'bool'].includes(simpleType)) {
112
+ return this.getBooleanTypeDeclarationSQL();
113
+ }
114
+ if (['varchar', 'character varying'].includes(simpleType)) {
115
+ return this.getVarcharTypeDeclarationSQL(options);
116
+ }
117
+ if (['char', 'bpchar'].includes(simpleType)) {
118
+ return this.getCharTypeDeclarationSQL(options);
119
+ }
120
+ if (['decimal', 'numeric'].includes(simpleType)) {
121
+ return this.getDecimalTypeDeclarationSQL(options);
122
+ }
123
+ if (['interval'].includes(simpleType)) {
124
+ return this.getIntervalTypeDeclarationSQL(options);
125
+ }
126
+ return super.normalizeColumnType(type, options);
127
+ }
100
128
  getMappedType(type) {
101
129
  switch (this.extractSimpleType(type)) {
102
130
  case 'tsvector': return core_1.Type.getType(FullTextType_1.FullTextType);
@@ -173,6 +201,9 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
173
201
  }
174
202
  return super.getCharTypeDeclarationSQL(column);
175
203
  }
204
+ getIntervalTypeDeclarationSQL(column) {
205
+ return 'interval' + (column.length != null ? `(${column.length})` : '');
206
+ }
176
207
  getBlobDeclarationSQL() {
177
208
  return 'bytea';
178
209
  }
@@ -130,10 +130,13 @@ class PostgreSqlSchemaHelper extends knex_1.SchemaHelper {
130
130
  let type = col.data_type.toLowerCase() === 'array'
131
131
  ? col.udt_name.replace(/^_(.*)$/, '$1[]')
132
132
  : col.udt_name;
133
+ if (type === 'bpchar') {
134
+ type = 'char';
135
+ }
133
136
  if (type === 'vector' && col.length == null && col.custom_length != null) {
134
137
  col.length = col.custom_length;
135
138
  }
136
- if (col.length != null && !type.endsWith(`(${col.length})`)) {
139
+ if (col.length != null && !type.endsWith(`(${col.length})`) && !['text', 'date'].includes(type)) {
137
140
  type += `(${col.length})`;
138
141
  }
139
142
  if (type === 'numeric' && col.numeric_precision != null && col.numeric_scale != null) {
@@ -531,6 +534,7 @@ class PostgreSqlSchemaHelper extends knex_1.SchemaHelper {
531
534
  return -1;
532
535
  case 'interval':
533
536
  case 'time':
537
+ case 'timestamp':
534
538
  case 'timestamptz':
535
539
  return this.platform.getDefaultDateTimeLength();
536
540
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/postgresql",
3
- "version": "6.3.5-dev.17",
3
+ "version": "6.3.5-dev.18",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -58,7 +58,7 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@mikro-orm/knex": "6.3.5-dev.17",
61
+ "@mikro-orm/knex": "6.3.5-dev.18",
62
62
  "pg": "8.12.0",
63
63
  "postgres-array": "3.0.2",
64
64
  "postgres-date": "2.1.0",
@@ -68,6 +68,6 @@
68
68
  "@mikro-orm/core": "^6.3.4"
69
69
  },
70
70
  "peerDependencies": {
71
- "@mikro-orm/core": "6.3.5-dev.17"
71
+ "@mikro-orm/core": "6.3.5-dev.18"
72
72
  }
73
73
  }