Fix/join single presFix QueryBuilder JOIN state when using singleerve joins - #2578
Merged
an-tao merged 2 commits intoSep 3, 2026
Merged
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.
Fix QueryBuilder JOIN state when using single
Summary
QueryBuilderto a single-result builder.Rowresults withLEFT JOIN + single().Problem
TransformBuilder::single()converts a non-single builder into a single-result builder. The conversion constructor copied the existing query state except forjoins_.As a result, a query such as:
QueryBuilder<Users>{} .from("users") .select("wallets.amount") .leftJoin("wallets", "users.user_id", "wallets.user_id") .limit(1) .single() .execSync(clientPtr);lost its
LEFT JOINclause. The generated SQL still referencedwallets.amount, causing a database error or incorrect query behavior.Changes
Copy
joins_in theTransformBuilder<T, SelectAll, true>conversion constructor:this->joins_ = tb.joins_;This keeps
FROM, JOIN, filters, ordering, limit, and offset unchanged when.single()only changes the result cardinality.Tests
LEFT JOIN + single().Row-result regression tests that selectwallets.amount.orm_lib/tests/db_test.cc.clang-formatandgit diff --checkpassed.Fixes #2577