fix(gdb): inject soft delete condition into LEFT JOIN ON clause instead of WHERE - #4816
Open
waterWang wants to merge 1 commit into
Open
fix(gdb): inject soft delete condition into LEFT JOIN ON clause instead of WHERE#4816waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
…ad of WHERE For LEFT JOIN queries, the soft delete condition (deleted_at = 0) was previously added to the WHERE clause, which turns the LEFT JOIN into an INNER JOIN — filtering out rows from the main table when the joined table has no matching row. This fix detects LEFT JOINs and injects the soft delete condition into the ON clause instead, preserving the LEFT JOIN semantics. For example, the generated SQL changes from: LEFT JOIN member ON (member.id = t.author_id) WHERE ... AND member.deleted_at = 0 To: LEFT JOIN member ON (member.id = t.author_id AND member.deleted_at = 0) WHERE ... (only base table condition) Closes gogf#4754
waterWang
force-pushed
the
fix/left-join-soft-delete-condition
branch
from
July 29, 2026 00:48
c8b7c81 to
deff85c
Compare
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
For LEFT JOIN queries, the soft delete condition (
deleted_at = 0) was previously added to the WHERE clause, which turns the LEFT JOIN into an INNER JOIN — filtering out rows from the main table when the joined table has no matching row.Change
This fix detects LEFT JOINs and injects the soft delete condition into the ON clause instead, preserving the LEFT JOIN semantics.
Before (broken)
After (fixed)
What changed
database/gdb/gdb_model_soft_time.go: ModifiedGetDeleteConditionto detect LEFT JOINs and inject the soft delete condition into the ON clause instead of the WHERE clauseinjectSoftDeleteIntoLeftJoinOnClausehelper methodTesting
The fix has been verified against the existing test suite. The soft time feature tests in
contrib/drivers/*/*_z_unit_feature_soft_time_test.gocontinue to pass.Related
Closes #4754