fix: include asExpression columns in returning clause #8472
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #8450
It is a bit unclear wether the
isGeneratedproperty onTableColumnandColumnMetadata(and possibly in more places) should be set only ifgenerationStrategyis defined as well. The property description in theColumnMetadataclass mentions it is meant for columns of "generated other way" (I read this as "any type of generation", includingasExpression), but most of the code that utilizes theisGeneratedfield often does not adhere to this.typeorm/src/metadata/ColumnMetadata.ts
Lines 83 to 86 in cefddd9
Perhaps this comment refers only to other generation strategies, like
uuid?I could think of two ways to solve the issue:
isGeneratedproperty is not restricted to generation strategies: go through all references ofisGeneratedand confirm or rewrite parts to makeisGenerateda universal indicator for columns that are generated in some way.isGeneratedshould only be used for generation strategies. The fix to the actual issue would then be simple: change line 181 of the condition below totypeorm/src/query-builder/ReturningResultsEntityUpdator.ts
Lines 172 to 187 in 90a8deb
This makes it such that columns with an
asExpressionare also included in theRETURNINGclause when saving an entity.Pull-Request Checklist
masterbranchnpm run lintpasses with this changenpm run testpasses with this changeFixes #0000(I updated documentation in the source files, not docs directory)