@mikro-orm/postgresql 7.0.0-dev.2 → 7.0.0-dev.200
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.d.ts +1 -1
- package/PostgreSqlConnection.js +6 -6
- package/PostgreSqlDriver.d.ts +8 -2
- package/PostgreSqlDriver.js +13 -1
- package/PostgreSqlEntityManager.d.ts +18 -0
- package/PostgreSqlEntityManager.js +23 -0
- package/PostgreSqlMikroORM.d.ts +7 -8
- package/PostgreSqlMikroORM.js +6 -8
- package/PostgreSqlPlatform.d.ts +2 -100
- package/PostgreSqlPlatform.js +12 -350
- package/README.md +3 -2
- package/index.d.ts +4 -5
- package/index.js +3 -4
- package/package.json +10 -10
- package/raw.d.ts +58 -0
- package/raw.js +64 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/PostgreSqlExceptionConverter.d.ts +0 -8
- package/PostgreSqlExceptionConverter.js +0 -48
- package/PostgreSqlSchemaHelper.d.ts +0 -56
- package/PostgreSqlSchemaHelper.js +0 -541
- package/types/FullTextType.d.ts +0 -14
- package/types/FullTextType.js +0 -59
- package/types/index.d.ts +0 -1
- package/types/index.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PoolConfig } from 'pg';
|
|
2
2
|
import { PostgresDialect } from 'kysely';
|
|
3
|
-
import { AbstractSqlConnection } from '@mikro-orm/
|
|
3
|
+
import { AbstractSqlConnection } from '@mikro-orm/sql';
|
|
4
4
|
export declare class PostgreSqlConnection extends AbstractSqlConnection {
|
|
5
5
|
createKyselyDialect(overrides: PoolConfig): PostgresDialect;
|
|
6
6
|
mapOptions(overrides: PoolConfig): PoolConfig;
|
package/PostgreSqlConnection.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import TypeOverrides from 'pg
|
|
2
|
-
import
|
|
1
|
+
import { Pool, TypeOverrides } from 'pg';
|
|
2
|
+
import Cursor from 'pg-cursor';
|
|
3
3
|
import { PostgresDialect } from 'kysely';
|
|
4
4
|
import array from 'postgres-array';
|
|
5
|
-
import { AbstractSqlConnection, Utils } from '@mikro-orm/
|
|
5
|
+
import { AbstractSqlConnection, Utils } from '@mikro-orm/sql';
|
|
6
6
|
export class PostgreSqlConnection extends AbstractSqlConnection {
|
|
7
7
|
createKyselyDialect(overrides) {
|
|
8
8
|
const options = this.mapOptions(overrides);
|
|
9
9
|
return new PostgresDialect({
|
|
10
10
|
pool: new Pool(options),
|
|
11
|
+
cursor: Cursor,
|
|
11
12
|
onCreateConnection: this.options.onCreateConnection ?? this.config.get('onCreateConnection'),
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
mapOptions(overrides) {
|
|
15
16
|
const ret = { ...this.getConnectionOptions() };
|
|
16
17
|
const pool = this.config.get('pool');
|
|
17
|
-
ret
|
|
18
|
-
ret
|
|
19
|
-
ret.idleTimeoutMillis = pool?.idleTimeoutMillis;
|
|
18
|
+
Utils.defaultValue(ret, 'max', pool?.max);
|
|
19
|
+
Utils.defaultValue(ret, 'idleTimeoutMillis', pool?.idleTimeoutMillis);
|
|
20
20
|
// use `select typname, oid, typarray from pg_type order by oid` to get the list of OIDs
|
|
21
21
|
const types = new TypeOverrides();
|
|
22
22
|
[
|
package/PostgreSqlDriver.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { AbstractSqlDriver } from '@mikro-orm/
|
|
1
|
+
import { type Configuration, type Constructor, EntityManagerType } from '@mikro-orm/core';
|
|
2
|
+
import { AbstractSqlDriver } from '@mikro-orm/sql';
|
|
3
3
|
import { PostgreSqlConnection } from './PostgreSqlConnection.js';
|
|
4
|
+
import { PostgreSqlMikroORM } from './PostgreSqlMikroORM.js';
|
|
5
|
+
import { PostgreSqlEntityManager } from './PostgreSqlEntityManager.js';
|
|
4
6
|
export declare class PostgreSqlDriver extends AbstractSqlDriver<PostgreSqlConnection> {
|
|
7
|
+
[EntityManagerType]: PostgreSqlEntityManager<this>;
|
|
5
8
|
constructor(config: Configuration);
|
|
9
|
+
createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
|
|
10
|
+
/** @inheritDoc */
|
|
11
|
+
getORMClass(): Constructor<PostgreSqlMikroORM>;
|
|
6
12
|
}
|
package/PostgreSqlDriver.js
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EntityManagerType } from '@mikro-orm/core';
|
|
2
|
+
import { AbstractSqlDriver } from '@mikro-orm/sql';
|
|
2
3
|
import { PostgreSqlConnection } from './PostgreSqlConnection.js';
|
|
3
4
|
import { PostgreSqlPlatform } from './PostgreSqlPlatform.js';
|
|
5
|
+
import { PostgreSqlMikroORM } from './PostgreSqlMikroORM.js';
|
|
6
|
+
import { PostgreSqlEntityManager } from './PostgreSqlEntityManager.js';
|
|
4
7
|
export class PostgreSqlDriver extends AbstractSqlDriver {
|
|
8
|
+
[EntityManagerType];
|
|
5
9
|
constructor(config) {
|
|
6
10
|
super(config, new PostgreSqlPlatform(), PostgreSqlConnection, ['kysely', 'pg']);
|
|
7
11
|
}
|
|
12
|
+
createEntityManager(useContext) {
|
|
13
|
+
const EntityManagerClass = this.config.get('entityManager', PostgreSqlEntityManager);
|
|
14
|
+
return new EntityManagerClass(this.config, this, this.metadata, useContext);
|
|
15
|
+
}
|
|
16
|
+
/** @inheritDoc */
|
|
17
|
+
getORMClass() {
|
|
18
|
+
return PostgreSqlMikroORM;
|
|
19
|
+
}
|
|
8
20
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type EntityName } from '@mikro-orm/core';
|
|
2
|
+
import { SqlEntityManager } from '@mikro-orm/sql';
|
|
3
|
+
import type { PostgreSqlDriver } from './PostgreSqlDriver.js';
|
|
4
|
+
/**
|
|
5
|
+
* @inheritDoc
|
|
6
|
+
*/
|
|
7
|
+
export declare class PostgreSqlEntityManager<Driver extends PostgreSqlDriver = PostgreSqlDriver> extends SqlEntityManager<Driver> {
|
|
8
|
+
/**
|
|
9
|
+
* Refreshes a materialized view.
|
|
10
|
+
*
|
|
11
|
+
* @param entityName - The entity name or class of the materialized view
|
|
12
|
+
* @param options - Optional settings
|
|
13
|
+
* @param options.concurrently - If true, refreshes the view concurrently (requires a unique index on the view)
|
|
14
|
+
*/
|
|
15
|
+
refreshMaterializedView<Entity extends object>(entityName: EntityName<Entity>, options?: {
|
|
16
|
+
concurrently?: boolean;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SqlEntityManager } from '@mikro-orm/sql';
|
|
2
|
+
/**
|
|
3
|
+
* @inheritDoc
|
|
4
|
+
*/
|
|
5
|
+
export class PostgreSqlEntityManager extends SqlEntityManager {
|
|
6
|
+
/**
|
|
7
|
+
* Refreshes a materialized view.
|
|
8
|
+
*
|
|
9
|
+
* @param entityName - The entity name or class of the materialized view
|
|
10
|
+
* @param options - Optional settings
|
|
11
|
+
* @param options.concurrently - If true, refreshes the view concurrently (requires a unique index on the view)
|
|
12
|
+
*/
|
|
13
|
+
async refreshMaterializedView(entityName, options) {
|
|
14
|
+
const meta = this.getMetadata(entityName);
|
|
15
|
+
if (!meta.view || !meta.materialized) {
|
|
16
|
+
throw new Error(`Entity ${meta.className} is not a materialized view`);
|
|
17
|
+
}
|
|
18
|
+
const helper = this.getDriver().getPlatform().getSchemaHelper();
|
|
19
|
+
const schema = meta.schema ?? this.config.get('schema');
|
|
20
|
+
const sql = helper.refreshMaterializedView(meta.tableName, schema, options?.concurrently);
|
|
21
|
+
await this.execute(sql);
|
|
22
|
+
}
|
|
23
|
+
}
|
package/PostgreSqlMikroORM.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType } from '@mikro-orm/core';
|
|
1
|
+
import { type AnyEntity, type EntityClass, type EntitySchema, MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType } from '@mikro-orm/core';
|
|
2
2
|
import { PostgreSqlDriver } from './PostgreSqlDriver.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PostgreSqlEntityManager } from './PostgreSqlEntityManager.js';
|
|
4
|
+
export type PostgreSqlOptions<EM extends PostgreSqlEntityManager = PostgreSqlEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = Options<PostgreSqlDriver, EM, Entities>;
|
|
5
|
+
export declare function definePostgreSqlConfig<EM extends PostgreSqlEntityManager = PostgreSqlEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<PostgreSqlDriver, EM, Entities>): Options<PostgreSqlDriver, EM, Entities>;
|
|
4
6
|
/**
|
|
5
7
|
* @inheritDoc
|
|
6
8
|
*/
|
|
7
|
-
export declare class PostgreSqlMikroORM<EM extends
|
|
8
|
-
private static DRIVER;
|
|
9
|
+
export declare class PostgreSqlMikroORM<EM extends PostgreSqlEntityManager = PostgreSqlEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends MikroORM<PostgreSqlDriver, EM, Entities> {
|
|
9
10
|
/**
|
|
10
11
|
* @inheritDoc
|
|
11
12
|
*/
|
|
12
|
-
static init<D extends IDatabaseDriver = PostgreSqlDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager>(options
|
|
13
|
+
static init<D extends IDatabaseDriver = PostgreSqlDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): Promise<MikroORM<D, EM, Entities>>;
|
|
13
14
|
/**
|
|
14
15
|
* @inheritDoc
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
constructor(options: Options<PostgreSqlDriver, EM, Entities>);
|
|
17
18
|
}
|
|
18
|
-
export type PostgreSqlOptions = Options<PostgreSqlDriver>;
|
|
19
|
-
export declare function definePostgreSqlConfig(options: PostgreSqlOptions): Options<PostgreSqlDriver, SqlEntityManager<PostgreSqlDriver> & EntityManager<IDatabaseDriver<import("@mikro-orm/core").Connection>>>;
|
package/PostgreSqlMikroORM.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { defineConfig, MikroORM, } from '@mikro-orm/core';
|
|
2
2
|
import { PostgreSqlDriver } from './PostgreSqlDriver.js';
|
|
3
|
+
export function definePostgreSqlConfig(options) {
|
|
4
|
+
return defineConfig({ driver: PostgreSqlDriver, ...options });
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* @inheritDoc
|
|
5
8
|
*/
|
|
6
9
|
export class PostgreSqlMikroORM extends MikroORM {
|
|
7
|
-
static DRIVER = PostgreSqlDriver;
|
|
8
10
|
/**
|
|
9
11
|
* @inheritDoc
|
|
10
12
|
*/
|
|
11
13
|
static async init(options) {
|
|
12
|
-
return super.init(options);
|
|
14
|
+
return super.init(definePostgreSqlConfig(options));
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* @inheritDoc
|
|
16
18
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super(definePostgreSqlConfig(options));
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
|
-
/* v8 ignore next 3 */
|
|
22
|
-
export function definePostgreSqlConfig(options) {
|
|
23
|
-
return defineConfig({ driver: PostgreSqlDriver, ...options });
|
|
24
|
-
}
|
package/PostgreSqlPlatform.d.ts
CHANGED
|
@@ -1,110 +1,12 @@
|
|
|
1
1
|
import { type IPostgresInterval } from 'postgres-interval';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { PostgreSqlSchemaHelper } from './PostgreSqlSchemaHelper.js';
|
|
5
|
-
import { PostgreSqlExceptionConverter } from './PostgreSqlExceptionConverter.js';
|
|
6
|
-
export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
|
|
7
|
-
protected readonly schemaHelper: PostgreSqlSchemaHelper;
|
|
8
|
-
protected readonly exceptionConverter: PostgreSqlExceptionConverter;
|
|
9
|
-
setConfig(config: Configuration): void;
|
|
10
|
-
createNativeQueryBuilder(): PostgreSqlNativeQueryBuilder;
|
|
11
|
-
usesReturningStatement(): boolean;
|
|
12
|
-
usesCascadeStatement(): boolean;
|
|
13
|
-
supportsNativeEnums(): boolean;
|
|
14
|
-
usesEnumCheckConstraints(): boolean;
|
|
15
|
-
supportsCustomPrimaryKeyNames(): boolean;
|
|
16
|
-
getCurrentTimestampSQL(length: number): string;
|
|
17
|
-
getDateTimeTypeDeclarationSQL(column: {
|
|
18
|
-
length?: number;
|
|
19
|
-
}): string;
|
|
20
|
-
getDefaultDateTimeLength(): number;
|
|
2
|
+
import { BasePostgreSqlPlatform } from '@mikro-orm/sql';
|
|
3
|
+
export declare class PostgreSqlPlatform extends BasePostgreSqlPlatform {
|
|
21
4
|
convertIntervalToJSValue(value: string): unknown;
|
|
22
5
|
convertIntervalToDatabaseValue(value: IPostgresInterval): unknown;
|
|
23
|
-
getTimeTypeDeclarationSQL(): string;
|
|
24
|
-
getIntegerTypeDeclarationSQL(column: {
|
|
25
|
-
length?: number;
|
|
26
|
-
autoincrement?: boolean;
|
|
27
|
-
generated?: string;
|
|
28
|
-
}): string;
|
|
29
|
-
getBigIntTypeDeclarationSQL(column: {
|
|
30
|
-
autoincrement?: boolean;
|
|
31
|
-
}): string;
|
|
32
|
-
getTinyIntTypeDeclarationSQL(column: {
|
|
33
|
-
length?: number;
|
|
34
|
-
unsigned?: boolean;
|
|
35
|
-
autoincrement?: boolean;
|
|
36
|
-
}): string;
|
|
37
|
-
getUuidTypeDeclarationSQL(column: {
|
|
38
|
-
length?: number;
|
|
39
|
-
}): string;
|
|
40
|
-
getFullTextWhereClause(prop: EntityProperty): string;
|
|
41
|
-
supportsCreatingFullTextIndex(): boolean;
|
|
42
|
-
getFullTextIndexExpression(indexName: string, schemaName: string | undefined, tableName: string, columns: SimpleColumnMeta[]): string;
|
|
43
|
-
normalizeColumnType(type: string, options: {
|
|
44
|
-
length?: number;
|
|
45
|
-
precision?: number;
|
|
46
|
-
scale?: number;
|
|
47
|
-
autoincrement?: boolean;
|
|
48
|
-
}): string;
|
|
49
|
-
getMappedType(type: string): Type<unknown>;
|
|
50
|
-
getRegExpOperator(val?: unknown, flags?: string): string;
|
|
51
|
-
getRegExpValue(val: RegExp): {
|
|
52
|
-
$re: string;
|
|
53
|
-
$flags?: string;
|
|
54
|
-
};
|
|
55
|
-
isBigIntProperty(prop: EntityProperty): boolean;
|
|
56
|
-
getArrayDeclarationSQL(): string;
|
|
57
|
-
getFloatDeclarationSQL(): string;
|
|
58
|
-
getDoubleDeclarationSQL(): string;
|
|
59
|
-
getEnumTypeDeclarationSQL(column: {
|
|
60
|
-
fieldNames: string[];
|
|
61
|
-
items?: unknown[];
|
|
62
|
-
nativeEnumName?: string;
|
|
63
|
-
}): string;
|
|
64
|
-
supportsMultipleStatements(): boolean;
|
|
65
|
-
getBeginTransactionSQL(options?: {
|
|
66
|
-
isolationLevel?: IsolationLevel;
|
|
67
|
-
readOnly?: boolean;
|
|
68
|
-
}): string[];
|
|
69
|
-
marshallArray(values: string[]): string;
|
|
70
6
|
unmarshallArray(value: string): string[];
|
|
71
|
-
getVarcharTypeDeclarationSQL(column: {
|
|
72
|
-
length?: number;
|
|
73
|
-
}): string;
|
|
74
|
-
getCharTypeDeclarationSQL(column: {
|
|
75
|
-
length?: number;
|
|
76
|
-
}): string;
|
|
77
|
-
getIntervalTypeDeclarationSQL(column: {
|
|
78
|
-
length?: number;
|
|
79
|
-
}): string;
|
|
80
|
-
getBlobDeclarationSQL(): string;
|
|
81
|
-
getJsonDeclarationSQL(): string;
|
|
82
|
-
getSearchJsonPropertyKey(path: string[], type: string | undefined | Type, aliased: boolean, value?: unknown): string;
|
|
83
|
-
getJsonIndexDefinition(index: IndexDef): string[];
|
|
84
|
-
quoteIdentifier(id: string, quote?: string): string;
|
|
85
7
|
escape(value: any): string;
|
|
86
|
-
private pad;
|
|
87
|
-
/** @internal */
|
|
88
|
-
formatDate(date: Date): string;
|
|
89
|
-
indexForeignKeys(): boolean;
|
|
90
|
-
getDefaultMappedType(type: string): Type<unknown>;
|
|
91
|
-
supportsSchemas(): boolean;
|
|
92
|
-
getDefaultSchemaName(): string | undefined;
|
|
93
|
-
/**
|
|
94
|
-
* Returns the default name of index for the given columns
|
|
95
|
-
* cannot go past 63 character length for identifiers in MySQL
|
|
96
|
-
*/
|
|
97
|
-
getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence'): string;
|
|
98
|
-
getDefaultPrimaryName(tableName: string, columns: string[]): string;
|
|
99
|
-
/**
|
|
100
|
-
* @inheritDoc
|
|
101
|
-
*/
|
|
102
|
-
castColumn(prop?: {
|
|
103
|
-
columnTypes?: string[];
|
|
104
|
-
}): string;
|
|
105
8
|
/**
|
|
106
9
|
* @inheritDoc
|
|
107
10
|
*/
|
|
108
11
|
parseDate(value: string | number): Date;
|
|
109
|
-
getDefaultClientUrl(): string;
|
|
110
12
|
}
|