Comments (6)
Let me know if you need a minimum reproducible example. I can put something together but had to significantly simplify the above classes because it comes from a fairly complex app with many more properties. I was hoping that it might be an obvious use case to replicate and fix.
from mikro-orm.
Let me know if you need a minimum reproducible example
I always need one :)
@manytoone(() => PageRevision, {
primary: true,
fieldName: 'page_revision_id',
onUpdate: () => 'cascade',
onDelete: 'cascade',
})
pageRevision: PageRevision;
This is surely wrong, and won't even compile in v6. onUpdate: () => 'cascade'
means you update the value to a string cascade
every time, and in v6 onDelete
is renamed to deleteRule
. Which brings me to a question, are you really on v6? And did you really reproduce with such entities?
So yes, complete repro needed, because this is suspicious on its own.
from mikro-orm.
Yes, we are on v6 and yes it does compile. I'll put together a repro.
from mikro-orm.
Yes, we are on v6 and yes it does compile.
Your screenshot is not the same as what you have put into the issue description. Note the deleteRule
(on screenshot) vs onDelete
(in the issue).
And either way, what I said above about the onUpdate
is correct too, using onUpdate: () => 'cascade'
is wrong, you want updateRule: 'cascade'
.
from mikro-orm.
Sorry, I simplified the entities and I must have based them on a different branch or something. What's in the screenshot is right.
from mikro-orm.
Here is a passing repro, let's reopen with a failing one:
import { Entity, MikroORM, Property, ManyToOne, Collection, ManyToMany, Formula, PrimaryKey } from '@mikro-orm/sqlite';
import { mockLogger } from '../../helpers';
@Entity()
class User {
@PrimaryKey()
id!: number;
@Property({ nullable: true })
firstName?: string;
@Property({ nullable: true })
lastName?: string;
@Property({ nullable: true })
email?: string;
@Formula(alias => `CONCAT(${alias}.first_name, ' ', ${alias}.last_name)`)
fullName?: string;
@Formula(alias => `LOWER(${alias}.email)`)
emailLower?: string;
}
@Entity()
class PageRevision {
@PrimaryKey()
id!: number;
@ManyToMany({
entity: () => User,
pivotEntity: () => PageRevisionUser,
})
users = new Collection<User>(this);
}
@Entity()
class PageRevisionUser {
@ManyToOne(() => PageRevision, { primary: true })
pageRevision!: PageRevision;
@ManyToOne(() => User, { primary: true })
user!: User;
}
let orm: MikroORM;
beforeAll(async () => {
orm = await MikroORM.init({
dbName: ':memory:',
entities: [PageRevision, User, PageRevisionUser],
debug: true,
});
await orm.schema.refreshDatabase();
});
afterAll(async () => {
await orm.close(true);
});
test('GH #5319', async () => {
const mock = mockLogger(orm);
await orm.em.findAll(PageRevision, { populate: ['users'] });
expect(mock.mock.calls[0][0]).toMatch('select `p0`.*, `u1`.`id` as `u1__id`, `u1`.`first_name` as `u1__first_name`, `u1`.`last_name` as `u1__last_name`, `u1`.`email` as `u1__email`, CONCAT(`u1`.first_name, \' \', `u1`.last_name) as `u1__full_name`, LOWER(`u1`.email) as `u1__email_lower` ' +
'from `page_revision` as `p0` ' +
'left join `page_revision_user` as `p2` on `p0`.`id` = `p2`.`page_revision_id` ' +
'left join `user` as `u1` on `p2`.`user_id` = `u1`.`id`');
});
from mikro-orm.
Related Issues (20)
- Filter with Embeddable array leads to InvalidFieldNameException even with autoJoinRefsForFilters: false
- Add an option to ignore nested entities when using assign HOT 1
- Cannot create a composite index on a Json column and a regular column
- nativeDelete fails with persist: false HOT 1
- Using populate ":ref" only return one item of the collection being populated
- Type mismatch between class Migration and interface Migration HOT 1
- Does MikroORM support encapsulation?
- Support `offset` in `findByCursor`
- Schema generator- Skip Tables and Skip Columns HOT 2
- Migratior up function throws error when running on Bun
- docs: Complete nested object are created and just id are linked
- ```forceUtcTimezone: true``` generates ```timestamptz``` type in migrations
- Passing logging to QueryBuilder
- Add support for Embedded column name HOT 4
- Support nullable values in cursor pagination HOT 1
- Automatic migration generation creates new changes even if schema is up to date HOT 1
- Entity Generator is extremely slow on large databases and has bugs HOT 13
- Maximum call stack exceed with double $none operator HOT 1
- I want to use mixin as base class but mikroorm dedup the base class by name
- Make the `getSingleResult()` add limit to the query
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mikro-orm.