@mikro-orm/sql 7.0.0-rc.3 → 7.0.1-dev.0
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/AbstractSqlConnection.d.ts +5 -4
- package/AbstractSqlConnection.js +18 -5
- package/AbstractSqlDriver.d.ts +1 -1
- package/AbstractSqlDriver.js +39 -10
- package/AbstractSqlPlatform.d.ts +34 -0
- package/AbstractSqlPlatform.js +47 -3
- package/PivotCollectionPersister.d.ts +2 -11
- package/PivotCollectionPersister.js +59 -59
- package/README.md +5 -4
- package/SqlEntityManager.d.ts +1 -1
- package/dialects/index.d.ts +1 -0
- package/dialects/index.js +1 -0
- package/dialects/mysql/BaseMySqlPlatform.d.ts +6 -0
- package/dialects/mysql/BaseMySqlPlatform.js +17 -0
- package/dialects/mysql/MySqlSchemaHelper.d.ts +1 -1
- package/dialects/mysql/MySqlSchemaHelper.js +6 -6
- package/dialects/oracledb/OracleDialect.d.ts +78 -0
- package/dialects/oracledb/OracleDialect.js +166 -0
- package/dialects/oracledb/OracleNativeQueryBuilder.d.ts +19 -0
- package/dialects/oracledb/OracleNativeQueryBuilder.js +249 -0
- package/dialects/oracledb/index.d.ts +2 -0
- package/dialects/oracledb/index.js +2 -0
- package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +6 -0
- package/dialects/postgresql/BasePostgreSqlPlatform.js +12 -8
- package/dialects/postgresql/PostgreSqlSchemaHelper.js +13 -13
- package/dialects/sqlite/SqlitePlatform.d.ts +1 -0
- package/dialects/sqlite/SqlitePlatform.js +3 -0
- package/dialects/sqlite/SqliteSchemaHelper.js +12 -8
- package/index.d.ts +1 -1
- package/index.js +0 -1
- package/package.json +3 -3
- package/plugin/index.d.ts +1 -14
- package/plugin/index.js +13 -13
- package/plugin/transformer.d.ts +6 -22
- package/plugin/transformer.js +81 -73
- package/query/ArrayCriteriaNode.d.ts +1 -1
- package/query/CriteriaNodeFactory.js +15 -3
- package/query/NativeQueryBuilder.d.ts +3 -3
- package/query/NativeQueryBuilder.js +4 -2
- package/query/ObjectCriteriaNode.js +4 -4
- package/query/QueryBuilder.d.ts +58 -62
- package/query/QueryBuilder.js +377 -370
- package/query/QueryBuilderHelper.d.ts +14 -11
- package/query/QueryBuilderHelper.js +324 -137
- package/query/ScalarCriteriaNode.js +3 -1
- package/query/enums.d.ts +2 -0
- package/query/enums.js +2 -0
- package/schema/DatabaseSchema.d.ts +7 -5
- package/schema/DatabaseSchema.js +50 -33
- package/schema/DatabaseTable.d.ts +8 -6
- package/schema/DatabaseTable.js +84 -60
- package/schema/SchemaComparator.d.ts +1 -3
- package/schema/SchemaComparator.js +22 -20
- package/schema/SchemaHelper.d.ts +2 -13
- package/schema/SchemaHelper.js +2 -1
- package/schema/SqlSchemaGenerator.d.ts +4 -14
- package/schema/SqlSchemaGenerator.js +15 -7
- package/typings.d.ts +4 -1
- package/tsconfig.build.tsbuildinfo +0 -1
package/query/QueryBuilder.d.ts
CHANGED
|
@@ -139,6 +139,57 @@ type GroupOperators<RootAlias extends string, Context, Entity, RawAliases extend
|
|
|
139
139
|
};
|
|
140
140
|
export type AliasedFilterCondition<RootAlias extends string, Context, Entity, RawAliases extends string = never> = (IsNever<RootAlias> extends true ? {} : string extends RootAlias ? {} : RootAliasFilterKeys<RootAlias, Entity>) & ([Context] extends [never] ? {} : ContextFilterKeys<Context>) & (IsNever<RawAliases> extends true ? {} : string extends RawAliases ? {} : RawFilterKeys<RawAliases>) & GroupOperators<RootAlias, Context, Entity, RawAliases>;
|
|
141
141
|
export type QBFilterQuery<Entity, RootAlias extends string = never, Context = never, RawAliases extends string = never> = FilterObject<Entity> & AliasedFilterCondition<RootAlias, Context, Entity, RawAliases>;
|
|
142
|
+
/** @internal */
|
|
143
|
+
export interface QBState<Entity extends object> {
|
|
144
|
+
type?: QueryType;
|
|
145
|
+
fields?: InternalField<Entity>[];
|
|
146
|
+
populate: PopulateOptions<Entity>[];
|
|
147
|
+
populateWhere?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
|
|
148
|
+
populateFilter?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
|
|
149
|
+
resolvedPopulateWhere?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
|
|
150
|
+
populateMap: Dictionary<string>;
|
|
151
|
+
aliasCounter: number;
|
|
152
|
+
flags: Set<QueryFlag>;
|
|
153
|
+
finalized: boolean;
|
|
154
|
+
populateHintFinalized: boolean;
|
|
155
|
+
joins: Dictionary<JoinOptions>;
|
|
156
|
+
explicitAlias: boolean;
|
|
157
|
+
schema?: string;
|
|
158
|
+
cond: Dictionary;
|
|
159
|
+
data?: Dictionary;
|
|
160
|
+
orderBy: QueryOrderMap<Entity>[];
|
|
161
|
+
groupBy: InternalField<Entity>[];
|
|
162
|
+
having: Dictionary;
|
|
163
|
+
returning?: InternalField<Entity>[];
|
|
164
|
+
onConflict?: OnConflictClause<Entity>[];
|
|
165
|
+
limit?: number;
|
|
166
|
+
offset?: number;
|
|
167
|
+
distinctOn?: string[];
|
|
168
|
+
joinedProps: Map<string, PopulateOptions<any>>;
|
|
169
|
+
cache?: boolean | number | [string, number];
|
|
170
|
+
indexHint?: string;
|
|
171
|
+
collation?: string;
|
|
172
|
+
comments: string[];
|
|
173
|
+
hintComments: string[];
|
|
174
|
+
flushMode?: FlushMode;
|
|
175
|
+
lockMode?: LockMode;
|
|
176
|
+
lockTables?: string[];
|
|
177
|
+
subQueries: Dictionary<string>;
|
|
178
|
+
mainAlias?: Alias<Entity>;
|
|
179
|
+
aliases: Dictionary<Alias<any>>;
|
|
180
|
+
tptAlias: Dictionary<string>;
|
|
181
|
+
unionQuery?: {
|
|
182
|
+
sql: string;
|
|
183
|
+
params: readonly unknown[];
|
|
184
|
+
};
|
|
185
|
+
ctes: (CteOptions & {
|
|
186
|
+
name: string;
|
|
187
|
+
query: NativeQueryBuilder | RawQueryFragment;
|
|
188
|
+
recursive?: boolean;
|
|
189
|
+
})[];
|
|
190
|
+
tptJoinsApplied: boolean;
|
|
191
|
+
autoJoinedPaths: string[];
|
|
192
|
+
}
|
|
142
193
|
/**
|
|
143
194
|
* SQL query builder with fluent interface.
|
|
144
195
|
*
|
|
@@ -159,6 +210,7 @@ export type QBFilterQuery<Entity, RootAlias extends string = never, Context = ne
|
|
|
159
210
|
* ```
|
|
160
211
|
*/
|
|
161
212
|
export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias extends string = never, Hint extends string = never, Context extends object = never, RawAliases extends string = never, Fields extends string = '*', CTEs extends Record<string, object> = {}> implements Subquery {
|
|
213
|
+
#private;
|
|
162
214
|
protected readonly metadata: MetadataStorage;
|
|
163
215
|
protected readonly driver: AbstractSqlDriver;
|
|
164
216
|
protected readonly context?: Transaction | undefined;
|
|
@@ -166,72 +218,15 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
|
|
|
166
218
|
protected em?: SqlEntityManager | undefined;
|
|
167
219
|
protected loggerContext?: (LoggingOptions & Dictionary) | undefined;
|
|
168
220
|
readonly __subquery: true;
|
|
221
|
+
/** @internal */
|
|
222
|
+
static createDefaultState<T extends object>(): QBState<T>;
|
|
169
223
|
get mainAlias(): Alias<Entity>;
|
|
170
224
|
get alias(): string;
|
|
171
225
|
get helper(): QueryBuilderHelper;
|
|
172
226
|
get type(): QueryType;
|
|
173
227
|
/** @internal */
|
|
174
|
-
|
|
175
|
-
/** @internal */
|
|
176
|
-
_fields?: InternalField<Entity>[];
|
|
177
|
-
/** @internal */
|
|
178
|
-
_populate: PopulateOptions<Entity>[];
|
|
179
|
-
/** @internal */
|
|
180
|
-
_populateWhere?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
|
|
181
|
-
/** @internal */
|
|
182
|
-
_populateFilter?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
|
|
183
|
-
/** @internal */
|
|
184
|
-
__populateWhere?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
|
|
185
|
-
/** @internal */
|
|
186
|
-
_populateMap: Dictionary<string>;
|
|
187
|
-
protected aliasCounter: number;
|
|
188
|
-
protected flags: Set<QueryFlag>;
|
|
189
|
-
protected finalized: boolean;
|
|
190
|
-
protected populateHintFinalized: boolean;
|
|
191
|
-
protected _joins: Dictionary<JoinOptions>;
|
|
192
|
-
protected _explicitAlias: boolean;
|
|
193
|
-
protected _schema?: string;
|
|
194
|
-
protected _cond: Dictionary;
|
|
195
|
-
protected _data: Dictionary;
|
|
196
|
-
protected _orderBy: QueryOrderMap<Entity>[];
|
|
197
|
-
protected _groupBy: InternalField<Entity>[];
|
|
198
|
-
protected _having: Dictionary;
|
|
199
|
-
protected _returning?: InternalField<Entity>[];
|
|
200
|
-
protected _onConflict?: OnConflictClause<Entity>[];
|
|
201
|
-
protected _limit?: number;
|
|
202
|
-
protected _offset?: number;
|
|
203
|
-
protected _distinctOn?: string[];
|
|
204
|
-
protected _joinedProps: Map<string, PopulateOptions<any>>;
|
|
205
|
-
protected _cache?: boolean | number | [string, number];
|
|
206
|
-
protected _indexHint?: string;
|
|
207
|
-
protected _collation?: string;
|
|
208
|
-
protected _comments: string[];
|
|
209
|
-
protected _hintComments: string[];
|
|
210
|
-
protected flushMode?: FlushMode;
|
|
211
|
-
protected lockMode?: LockMode;
|
|
212
|
-
protected lockTables?: string[];
|
|
213
|
-
protected subQueries: Dictionary<string>;
|
|
214
|
-
protected _mainAlias?: Alias<Entity>;
|
|
215
|
-
protected _aliases: Dictionary<Alias<any>>;
|
|
216
|
-
protected _tptAlias: Dictionary<string>;
|
|
217
|
-
protected _helper?: QueryBuilderHelper;
|
|
218
|
-
protected _query?: {
|
|
219
|
-
sql?: string;
|
|
220
|
-
params?: readonly unknown[];
|
|
221
|
-
qb: NativeQueryBuilder;
|
|
222
|
-
};
|
|
223
|
-
protected _unionQuery?: {
|
|
224
|
-
sql: string;
|
|
225
|
-
params: readonly unknown[];
|
|
226
|
-
};
|
|
227
|
-
protected _ctes: (CteOptions & {
|
|
228
|
-
name: string;
|
|
229
|
-
query: NativeQueryBuilder | RawQueryFragment;
|
|
230
|
-
recursive?: boolean;
|
|
231
|
-
})[];
|
|
228
|
+
get state(): QBState<Entity>;
|
|
232
229
|
protected readonly platform: AbstractSqlPlatform;
|
|
233
|
-
private tptJoinsApplied;
|
|
234
|
-
private readonly autoJoinedPaths;
|
|
235
230
|
/**
|
|
236
231
|
* @internal
|
|
237
232
|
*/
|
|
@@ -682,6 +677,7 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
|
|
|
682
677
|
*/
|
|
683
678
|
from<Name extends string & keyof CTEs, Alias extends string = Name>(target: Name, aliasName?: Alias): SelectQueryBuilder<CTEs[Name], Alias, never, never, never, '*', CTEs>;
|
|
684
679
|
getNativeQuery(processVirtualEntity?: boolean): NativeQueryBuilder;
|
|
680
|
+
protected processReturningStatement(qb: NativeQueryBuilder, meta?: EntityMetadata, data?: Dictionary, returning?: Field<any>[]): void;
|
|
685
681
|
/**
|
|
686
682
|
* Returns the query with parameters as wildcards.
|
|
687
683
|
*/
|
|
@@ -852,7 +848,7 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
|
|
|
852
848
|
*/
|
|
853
849
|
withRecursive<Name extends string>(name: Name, query: NativeQueryBuilder | RawQueryFragment, options?: CteOptions): QueryBuilder<Entity, RootAlias, Hint, Context, RawAliases, Fields, CTEs & Record<Name, object>>;
|
|
854
850
|
private addCte;
|
|
855
|
-
clone(reset?: boolean |
|
|
851
|
+
clone(reset?: boolean | (keyof QBState<Entity>)[], preserve?: (keyof QBState<Entity>)[]): QueryBuilder<Entity, RootAlias, Hint, Context, RawAliases, Fields, CTEs>;
|
|
856
852
|
/**
|
|
857
853
|
* Sets logger context for this query builder.
|
|
858
854
|
*/
|
|
@@ -877,7 +873,7 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
|
|
|
877
873
|
* For embeddeds: navigates into flattened embeddeds to return the correct field name.
|
|
878
874
|
*/
|
|
879
875
|
protected resolveNestedPath(field: string): string | string[];
|
|
880
|
-
|
|
876
|
+
protected init(type: QueryType, data?: any, cond?: any): this;
|
|
881
877
|
private getQueryBase;
|
|
882
878
|
private applyDiscriminatorCondition;
|
|
883
879
|
/**
|