Repository navigation
Fix withSql referencing a named shape column by its name (#903) - #909
Merged
IlyaSemenov merged 1 commit intoNov 17, 2026
Conversation
👷 Deploy request for orchid-orm pending review.Visit the deploys page to approve it
|
IlyaSemenov
deleted the
IlyaSemenov/withsql-a-shape-column-with-name-is-declared-by
branch
November 17, 2026 06:04
2 of 3 tasks
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 #903.
withSqldeclares the CTE columns by the keys of the shape, but selections, conditions, and joins refer to a column by itsname(). For a shape column withname(), the query fails withcolumn score.author_id does not exist.With this PR,
withSqlignoresname()of the shape columns, the same aswithdoes for the columns of a sub-query: the CTE columns are declared and referenced by the shape keys.Motivation
Another follow-up to #904 and #905, for the same ACL optimization: a
withSqlCTE whose shape reuses columns withname().Verification
Added database-backed tests for
withSqlwith a named column: referenced inselectandwhere, selected with all columns, and used in another CTE. The first fails without the fix, and all pass with it.pnpm verifypasses.Checklist
pnpm changeset) if this PR includes a feature or bug fix in a published package.