@mikro-orm/core 7.2.8-dev.7 → 7.2.8-dev.9
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/EntityManager.js +12 -2
- package/drivers/IDatabaseDriver.d.ts +2 -0
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
package/EntityManager.js
CHANGED
|
@@ -212,9 +212,14 @@ export class EntityManager {
|
|
|
212
212
|
await em.tryFlush(entityName, options);
|
|
213
213
|
const where = (await em.processWhere(entityName, options.where ?? {}, options, 'read'));
|
|
214
214
|
validateParams(where);
|
|
215
|
-
options.orderBy = options.orderBy || {};
|
|
216
|
-
options.populate = (await em.preparePopulate(entityName, options));
|
|
217
215
|
const meta = this.metadata.get(entityName);
|
|
216
|
+
if (meta.orderBy) {
|
|
217
|
+
options.orderBy = QueryHelper.mergeOrderBy(options.orderBy, meta.orderBy);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
options.orderBy ??= {};
|
|
221
|
+
}
|
|
222
|
+
options.populate = (await em.preparePopulate(entityName, options));
|
|
218
223
|
em.validateIndexUsage(meta, options.where ?? {}, options);
|
|
219
224
|
options = { ...options };
|
|
220
225
|
// save the original hint value so we know it was infer/all
|
|
@@ -858,6 +863,10 @@ export class EntityManager {
|
|
|
858
863
|
return em.lockAndPopulate(meta, entity, where, options);
|
|
859
864
|
}
|
|
860
865
|
validateParams(where);
|
|
866
|
+
// before the cache key so cached results share the merged orderBy
|
|
867
|
+
if (meta.orderBy) {
|
|
868
|
+
options.orderBy = QueryHelper.mergeOrderBy(options.orderBy, meta.orderBy);
|
|
869
|
+
}
|
|
861
870
|
options.populate = (await em.preparePopulate(entityName, options));
|
|
862
871
|
const cacheKey = em.cacheKey(entityName, options, 'em.findOne', where);
|
|
863
872
|
const cached = await em.tryCache(entityName, options.cache, cacheKey, options.refresh, true, options.schema);
|
|
@@ -1832,6 +1841,7 @@ export class EntityManager {
|
|
|
1832
1841
|
options.populateWhere = this.createPopulateWhere({ ...where }, options);
|
|
1833
1842
|
options.populateFilter = await this.getJoinedFilters(meta, options);
|
|
1834
1843
|
validateParams(where);
|
|
1844
|
+
em.validateIndexUsage(meta, where, options);
|
|
1835
1845
|
delete options.orderBy;
|
|
1836
1846
|
await em.processUnionWhere(entityName, options, 'read');
|
|
1837
1847
|
const cacheKey = em.cacheKey(entityName, options, 'em.count', where);
|
|
@@ -326,6 +326,8 @@ export interface CountOptions<T extends object, P extends string = never> extend
|
|
|
326
326
|
flushMode?: FlushMode | `${FlushMode}`;
|
|
327
327
|
/** SQL: appended to FROM clause (e.g. `'force index(my_index)'`); MongoDB: index name or spec passed as `hint`. */
|
|
328
328
|
indexHint?: string | Dictionary;
|
|
329
|
+
/** @see FindOptions.using */
|
|
330
|
+
using?: IndexName<T> | IndexName<T>[];
|
|
329
331
|
/** sql only */
|
|
330
332
|
comments?: string | string[];
|
|
331
333
|
/** sql only */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.8-dev.
|
|
3
|
+
"version": "7.2.8-dev.9",
|
|
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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
package/utils/Utils.js
CHANGED
|
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
|
|
|
153
153
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
154
154
|
export class Utils {
|
|
155
155
|
static PK_SEPARATOR = '~~~';
|
|
156
|
-
static #ORM_VERSION = '7.2.8-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.8-dev.9';
|
|
157
157
|
/** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
|
|
158
158
|
static getRlsSettingName(filterName, argName) {
|
|
159
159
|
return `mikro.${filterName}.${argName}`;
|