@mikro-orm/core 7.2.8-dev.6 → 7.2.8-dev.8
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 +11 -2
- 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);
|
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.8",
|
|
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.8';
|
|
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}`;
|