@mikro-orm/postgresql 7.0.0-dev.3 → 7.0.0-dev.30
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.
- package/PostgreSqlConnection.js +3 -5
- package/PostgreSqlPlatform.d.ts +3 -1
- package/PostgreSqlPlatform.js +8 -3
- package/PostgreSqlSchemaHelper.js +8 -3
- package/README.md +1 -2
- package/package.json +7 -7
package/PostgreSqlConnection.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import TypeOverrides from 'pg
|
|
2
|
-
import { Pool } from 'pg';
|
|
1
|
+
import { Pool, TypeOverrides } from 'pg';
|
|
3
2
|
import { PostgresDialect } from 'kysely';
|
|
4
3
|
import array from 'postgres-array';
|
|
5
4
|
import { AbstractSqlConnection, Utils } from '@mikro-orm/knex';
|
|
@@ -14,9 +13,8 @@ export class PostgreSqlConnection extends AbstractSqlConnection {
|
|
|
14
13
|
mapOptions(overrides) {
|
|
15
14
|
const ret = { ...this.getConnectionOptions() };
|
|
16
15
|
const pool = this.config.get('pool');
|
|
17
|
-
ret
|
|
18
|
-
ret
|
|
19
|
-
ret.idleTimeoutMillis = pool?.idleTimeoutMillis;
|
|
16
|
+
Utils.defaultValue(ret, 'max', pool?.max);
|
|
17
|
+
Utils.defaultValue(ret, 'idleTimeoutMillis', pool?.idleTimeoutMillis);
|
|
20
18
|
// use `select typname, oid, typarray from pg_type order by oid` to get the list of OIDs
|
|
21
19
|
const types = new TypeOverrides();
|
|
22
20
|
[
|
package/PostgreSqlPlatform.d.ts
CHANGED
|
@@ -81,7 +81,9 @@ export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
81
81
|
getJsonDeclarationSQL(): string;
|
|
82
82
|
getSearchJsonPropertyKey(path: string[], type: string | undefined | Type, aliased: boolean, value?: unknown): string;
|
|
83
83
|
getJsonIndexDefinition(index: IndexDef): string[];
|
|
84
|
-
quoteIdentifier(id: string
|
|
84
|
+
quoteIdentifier(id: string | {
|
|
85
|
+
toString: () => string;
|
|
86
|
+
}, quote?: string): string;
|
|
85
87
|
escape(value: any): string;
|
|
86
88
|
private pad;
|
|
87
89
|
/** @internal */
|
package/PostgreSqlPlatform.js
CHANGED
|
@@ -258,7 +258,7 @@ export class PostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
258
258
|
if (RawQueryFragment.isKnownFragment(id)) {
|
|
259
259
|
return super.quoteIdentifier(id);
|
|
260
260
|
}
|
|
261
|
-
return `${quote}${id.replace('.', `${quote}.${quote}`)}${quote}`;
|
|
261
|
+
return `${quote}${id.toString().replace('.', `${quote}.${quote}`)}${quote}`;
|
|
262
262
|
}
|
|
263
263
|
escape(value) {
|
|
264
264
|
if (typeof value === 'string') {
|
|
@@ -270,6 +270,9 @@ export class PostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
270
270
|
if (ArrayBuffer.isView(value)) {
|
|
271
271
|
return `E'\\\\x${value.toString('hex')}'`;
|
|
272
272
|
}
|
|
273
|
+
if (Array.isArray(value)) {
|
|
274
|
+
return value.map(v => this.escape(v)).join(', ');
|
|
275
|
+
}
|
|
273
276
|
return super.escape(value);
|
|
274
277
|
}
|
|
275
278
|
pad(number, digits) {
|
|
@@ -347,15 +350,17 @@ export class PostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
347
350
|
getIndexName(tableName, columns, type) {
|
|
348
351
|
const indexName = super.getIndexName(tableName, columns, type);
|
|
349
352
|
if (indexName.length > 63) {
|
|
353
|
+
const hashAlgorithm = this.config.get('hashAlgorithm');
|
|
350
354
|
const suffix = type === 'primary' ? 'pkey' : type;
|
|
351
|
-
return `${indexName.substring(0, 55 - type.length)}_${Utils.hash(indexName, 5)}_${suffix}`;
|
|
355
|
+
return `${indexName.substring(0, 55 - type.length)}_${Utils.hash(indexName, 5, hashAlgorithm)}_${suffix}`;
|
|
352
356
|
}
|
|
353
357
|
return indexName;
|
|
354
358
|
}
|
|
355
359
|
getDefaultPrimaryName(tableName, columns) {
|
|
356
360
|
const indexName = `${tableName}_pkey`;
|
|
357
361
|
if (indexName.length > 63) {
|
|
358
|
-
|
|
362
|
+
const hashAlgorithm = this.config.get('hashAlgorithm');
|
|
363
|
+
return `${indexName.substring(0, 55 - 'pkey'.length)}_${Utils.hash(indexName, 5, hashAlgorithm)}_pkey`;
|
|
359
364
|
}
|
|
360
365
|
return indexName;
|
|
361
366
|
}
|
|
@@ -250,10 +250,14 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
250
250
|
if (row.schema_name && row.schema_name !== this.platform.getDefaultSchemaName()) {
|
|
251
251
|
name = row.schema_name + '.' + name;
|
|
252
252
|
}
|
|
253
|
+
let items = row.enum_value;
|
|
254
|
+
if (!Array.isArray(items)) {
|
|
255
|
+
items = this.platform.unmarshallArray(row.enum_value);
|
|
256
|
+
}
|
|
253
257
|
o[name] = {
|
|
254
258
|
name: row.enum_name,
|
|
255
259
|
schema: row.schema_name,
|
|
256
|
-
items
|
|
260
|
+
items,
|
|
257
261
|
};
|
|
258
262
|
return o;
|
|
259
263
|
}, {});
|
|
@@ -317,7 +321,8 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
317
321
|
}, {});
|
|
318
322
|
}
|
|
319
323
|
createTableColumn(column, table) {
|
|
320
|
-
const
|
|
324
|
+
const pk = table.getPrimaryKey();
|
|
325
|
+
const compositePK = pk?.composite;
|
|
321
326
|
const primaryKey = !this.hasNonDefaultPrimaryKeyName(table);
|
|
322
327
|
const col = [this.quote(column.name)];
|
|
323
328
|
if (column.autoincrement && !column.generated && !compositePK) {
|
|
@@ -347,7 +352,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
347
352
|
Utils.runIfNotEmpty(() => col.push('null'), column.nullable);
|
|
348
353
|
Utils.runIfNotEmpty(() => col.push('not null'), !column.nullable);
|
|
349
354
|
}
|
|
350
|
-
if (column.autoincrement && !
|
|
355
|
+
if (column.autoincrement && !compositePK) {
|
|
351
356
|
Utils.runIfNotEmpty(() => col.push('primary key'), primaryKey && column.primary);
|
|
352
357
|
}
|
|
353
358
|
const useDefault = column.default != null && column.default !== 'null' && !column.autoincrement;
|
package/README.md
CHANGED
|
@@ -11,7 +11,6 @@ TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-or
|
|
|
11
11
|
[](https://discord.gg/w8bjxFHS7X)
|
|
12
12
|
[](https://www.npmjs.com/package/@mikro-orm/core)
|
|
13
13
|
[](https://coveralls.io/r/mikro-orm/mikro-orm?branch=master)
|
|
14
|
-
[](https://codeclimate.com/github/mikro-orm/mikro-orm/maintainability)
|
|
15
14
|
[](https://github.com/mikro-orm/mikro-orm/actions?workflow=tests)
|
|
16
15
|
|
|
17
16
|
## 🤔 Unit of What?
|
|
@@ -141,7 +140,7 @@ There is also auto-generated [CHANGELOG.md](CHANGELOG.md) file based on commit m
|
|
|
141
140
|
- [Composite and Foreign Keys as Primary Key](https://mikro-orm.io/docs/composite-keys)
|
|
142
141
|
- [Filters](https://mikro-orm.io/docs/filters)
|
|
143
142
|
- [Using `QueryBuilder`](https://mikro-orm.io/docs/query-builder)
|
|
144
|
-
- [
|
|
143
|
+
- [Populating relations](https://mikro-orm.io/docs/populating-relations)
|
|
145
144
|
- [Property Validation](https://mikro-orm.io/docs/property-validation)
|
|
146
145
|
- [Lifecycle Hooks](https://mikro-orm.io/docs/events#hooks)
|
|
147
146
|
- [Vanilla JS Support](https://mikro-orm.io/docs/usage-with-js)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/postgresql",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.30",
|
|
5
5
|
"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.",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@mikro-orm/knex": "7.0.0-dev.
|
|
54
|
-
"pg": "8.
|
|
55
|
-
"postgres-array": "3.0.
|
|
53
|
+
"@mikro-orm/knex": "7.0.0-dev.30",
|
|
54
|
+
"pg": "8.16.3",
|
|
55
|
+
"postgres-array": "3.0.4",
|
|
56
56
|
"postgres-date": "2.1.0",
|
|
57
57
|
"postgres-interval": "4.0.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@mikro-orm/core": "^6.
|
|
61
|
-
"kysely": "
|
|
60
|
+
"@mikro-orm/core": "^6.5.7",
|
|
61
|
+
"kysely": "0.28.7"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
64
|
+
"@mikro-orm/core": "7.0.0-dev.30",
|
|
65
65
|
"kysely": "*"
|
|
66
66
|
}
|
|
67
67
|
}
|