-
-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Virtual property causes incorrect MySQL query #5261
Comments
Why do you put it into the |
I added this info in the description: When the virtual property is omitted from the field options, the return type of the find function is no longer accurate, potentially causing issues with type checking and data handling downstream.
This broke while migrating to version 6. |
I see, and I'm afraid this might also mean it will not be part of the serialized form. And this worked in v5 or you had to add it when trying to migrate to v6? |
Yes, in v5 the returned type contained the virtual property rating without it being defined in the fields array. We had to add it while migrating because the returned Loaded type did not contain it anymore. |
I am asking whether it was possible to have the virtual property in fields hint, as I don't think that's the case. I understand why you've added there during the migration, that's indeed a valid point to address somehow. edit: it works the same in v5 and serialization is not a problem |
I have checked this again. Previously, the rating was not specified in the fields and was therefore not included in the database query. However, the return type of find was not a problem because the property was there, just like all the others. Now, with version 6, the property is no longer in the return type of find. Therefore, we tried to include the property in the fields, but this causes the error with the query. |
Describe the bug
When specifying a virtual property in the field options of the find function, the virtual property is erroneously included in the MySQL database query. This is problematic because virtual properties do not exist in the database, leading to incorrect query results or errors. Additionally, when the virtual property is omitted from the field options, the return type of the find function is no longer accurate, potentially causing issues with type checking and data handling downstream.
Reproduction
Define a virtual property in the model.
Use the find function with the virtual property specified in the field options.
Observe that the virtual property is included in the MySQL query.
What driver are you using?
@mikro-orm/mysql
MikroORM version
6.1.4
Node.js version
18.18.2
Operating system
Debian
Validations
The text was updated successfully, but these errors were encountered: