@mikro-orm/postgresql 6.3.5-dev.9 → 6.3.5

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) {
@@ -231,12 +234,12 @@ class PostgreSqlSchemaHelper extends knex_1.SchemaHelper {
231
234
  }
232
235
  async getNativeEnumDefinitions(connection, schemas) {
233
236
  const uniqueSchemas = core_1.Utils.unique(schemas);
234
- const res = await connection.execute(`select t.typname as enum_name, min(n.nspname) as schema_name, array_agg(e.enumlabel order by e.enumsortorder) as enum_value
237
+ const res = await connection.execute(`select t.typname as enum_name, n.nspname as schema_name, array_agg(e.enumlabel order by e.enumsortorder) as enum_value
235
238
  from pg_type t
236
239
  join pg_enum e on t.oid = e.enumtypid
237
240
  join pg_catalog.pg_namespace n on n.oid = t.typnamespace
238
241
  where n.nspname in (${Array(uniqueSchemas.length).fill('?').join(', ')})
239
- group by t.typname`, uniqueSchemas);
242
+ group by t.typname, n.nspname`, uniqueSchemas);
240
243
  return res.reduce((o, row) => {
241
244
  let name = row.enum_name;
242
245
  if (row.schema_name && row.schema_name !== this.platform.getDefaultSchemaName()) {
@@ -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/README.md CHANGED
@@ -143,7 +143,7 @@ There is also auto-generated [CHANGELOG.md](CHANGELOG.md) file based on commit m
143
143
  - [Using `QueryBuilder`](https://mikro-orm.io/docs/query-builder)
144
144
  - [Preloading Deeply Nested Structures via populate](https://mikro-orm.io/docs/nested-populate)
145
145
  - [Property Validation](https://mikro-orm.io/docs/property-validation)
146
- - [Lifecycle Hooks](https://mikro-orm.io/docs/lifecycle-hooks)
146
+ - [Lifecycle Hooks](https://mikro-orm.io/docs/events#hooks)
147
147
  - [Vanilla JS Support](https://mikro-orm.io/docs/usage-with-js)
148
148
  - [Schema Generator](https://mikro-orm.io/docs/schema-generator)
149
149
  - [Entity Generator](https://mikro-orm.io/docs/entity-generator)
@@ -163,6 +163,7 @@ You can find example integrations for some popular frameworks in the [`mikro-orm
163
163
  - [NextJS + MySQL](https://github.com/jonahallibone/mikro-orm-nextjs)
164
164
  - [Accounts.js REST and GraphQL authentication + SQLite](https://github.com/darkbasic/mikro-orm-accounts-example)
165
165
  - [Nest + Shopify + PostgreSQL + GraphQL](https://github.com/Cloudshelf/Shopify_CSConnector)
166
+ - [Elysia.js + libSQL + Bun](https://github.com/mikro-orm/elysia-bun-example-app)
166
167
 
167
168
  ### JavaScript Examples
168
169
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/postgresql",
3
- "version": "6.3.5-dev.9",
3
+ "version": "6.3.5",
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,16 +58,16 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@mikro-orm/knex": "6.3.5-dev.9",
61
+ "@mikro-orm/knex": "6.3.5",
62
62
  "pg": "8.12.0",
63
63
  "postgres-array": "3.0.2",
64
64
  "postgres-date": "2.1.0",
65
65
  "postgres-interval": "4.0.2"
66
66
  },
67
67
  "devDependencies": {
68
- "@mikro-orm/core": "^6.3.4"
68
+ "@mikro-orm/core": "^6.3.5"
69
69
  },
70
70
  "peerDependencies": {
71
- "@mikro-orm/core": "6.3.5-dev.9"
71
+ "@mikro-orm/core": "^6.0.0"
72
72
  }
73
73
  }