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
Unable to addSelect with computed result #7008
Comments
@Asarew I share your frustration at the lack of this feature for so long but this really isn't constructive. The developers are clearly aware of this and you are simply wasting their time by creating new issues. I am working on a solution that will hopefully satisfy all parties because personally I don't think any of the provided solutions are actually going to be good long term. |
@nebkat The bug that I'm describing here has nothing to do with |
@Asarew I think the fact that you have been able to link to comments, issues and pull requests that all describe your situation shows that this is a known and duplicate issue, which therefore makes this a waste of their time. I can assure you I have looked into your issue and all of the related issues from the past. In your example you are using a computed expression Additionally, your method of achieving this is by artificially recreating the alias that you would expect the standard column selection and mapping process to use, then hoping that it will be correctly mapped back to the entity property. Even if we were to ignore your motivations for mapping a computed expression to the column property and the associated issues, your intention was ultimately to have a When you combine these two things, the obvious solution is As I said, I am also frustrated by the lack of progress, especially when seeing the discussion go all the way back to 2017 - I am currently migrating a full stack to Nest/TypeORM and this is quite a major issue for me. However, the solution is not to merge quick hacks just because a full feature implementation is not ready. You have offered your solution and it was objected for good reasons, not "ignored". The great thing about this being an open source project is that you can fork it and apply whatever fixes you want for use in your own projects. |
You are correct that the annotated property should only contain the intended database value. that is one reason why i believe there is a difference between this bug fix and Additionally, your statement that the internal use of the mapping system is not relevant doesn't make sense to me as the selection of the alias is already used by typeorm to identify which property to populate. You add up the 2 items to come to the conclusion that only |
Please take a look at my proposed pull request for A core part of any ORM is that it does the mapping of raw database output to the object for you (its literally in the name I guess). As far as the designer is concerned, the only thing that really matters is the entity and its properties - how the ORM chooses to map from the object to the database and vice-versa is not nearly as important. Of course, sometimes we care about the names assigned to columns because they might be read directly from a non-ORM client, which is why we are given the freedom to define the column names ourselves, both manually and through naming schemes. Beyond that however, the ability of the ORM to map TypeORM happens to do this by generating column aliases in the form If your proposed change is adopted we then mix the internal mapping process with user input, when in reality you should not care about how the ORM goes about achieving this internally. |
when using a computed selection the property doesn't get hydrated
Expected Behavior
This would output
everything is all good
.Actual Behavior
Error is thrown:
text not hydrated
Are you willing to resolve this issue by submitting a Pull Request?
I've already fixed this issue in this PR: #4703 but it seems to getting ignored due to the fact that it doesn't support all use cases of the parties involved that are mainly interested in
addSelectAndMap
.But because a feature PR for that is currently in the works #6855, i think that we can just merge #4703 as it doesn't introduce any new features but fixes a Very long standing bug.
The text was updated successfully, but these errors were encountered: