-
-
Notifications
You must be signed in to change notification settings - Fork 611
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I use MongoDB with UnderscoreNamingStrategy
find and findOne with sort by camel case field do not work, sorting is ignored.
The problem seems to be exactly with Mongo driver.
To Reproduce
Steps to reproduce the behavior:
@Entity()
export class A {
@PrimaryKey()
_id = randomUUID();
@Property()
complexName!: string;
}
orm = await MikroORM.init({
entities: [A],
clientUrl: await initMongoReplSet('mikro-orm-test'),
driver: MongoDriver,
namingStrategy: UnderscoreNamingStrategy,
});
await orm.schema.clearDatabase()
const a = new A();
a.complexName = 'a';
const b = new A();
b.complexName = 'b';
await orm.em.persistAndFlush(a);
await orm.em.persistAndFlush(b);
orm.em.clear();
const data2 = await orm.em.find(A, {}, {
orderBy: { complexName: 'desc' },
});
expect(data2[0].complexName).toBe('b');
Expected behavior
Keys in orderBy should be transformed according to naming strategy.
Versions
| Dependency | Version |
|---|---|
| node | 18.14 |
| typescript | 4.9.5 |
| mikro-orm | 5 |
| your-driver | MongoDB |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working