{{ message }}
fix: expand virtual column query in WHERE clause conditions - #12844
Open
dikshit-n wants to merge 2 commits into
Open
fix: expand virtual column query in WHERE clause conditions#12844dikshit-n wants to merge 2 commits into
dikshit-n wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Summary
Fixes #11616 — VirtualColumn throws error when used in WHERE conditions.
When a
@VirtualColumnis used in a WHERE clause withcreateQueryBuilderobject-style conditions, TypeORM incorrectly tries to reference the virtual property name as a literal database column, which does not exist.Changes
File:
src/query-builder/QueryBuilder.tsgetPredicates(): Now detects virtual columns and expands the query expression in WHERE conditions instead of using the non-existent column path.buildConditionForVirtualColumn()(new): Builds SQL WHERE conditions for virtual columns by wrapping the computed query expression in appropriate operator syntax. HandlesEqual,MoreThan,LessThan,Like,In,Not,And,Or, and other operators.buildOperatorConditionForVirtualColumn()(new): Handles FindOperator types specifically for virtual column conditions.getWhereCondition(): Routes virtual column predicates to the new handler.File:
test/functional/columns/virtual-columns/virtual-columns.test.tsshould expand virtual column in WHERE clause with QueryBuilder object-style conditionExample
Before (broken — causes
Unknown column 'user.fullName' in 'where clause'):After (fixed):
Testing
TypeScript compiles cleanly with
pnpm typecheck. The new test verifies that theWHEREclause uses the expanded query expression.Closes #11616