Repository navigation
Replace else branches in Sql with guard clauses and match - #220
Merged
Merged
Conversation
Value-picking if/elseif chains become match (true) expressions and the rest return or continue early. AbstractSql gains a private helper that quotes a join's TableIdentifier, which keeps processJoin's match flat. Cover the join path for a TableIdentifier without a schema and the resolveTable path for an empty table, neither of which had a test. Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
simon-mundy
marked this pull request as ready for review
October 6, 2026 02:20
tyrsson
previously approved these changes
Oct 8, 2026
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.
Depends on #219. Until the earlier PRs in this series merge, this diff also shows their commits; the change here is the last commit, "Replace else branches in Sql with guard clauses and match".
Clears all 53
no-else-clauseMago lint findings insrc/Sql.Changes
match (true)expressions: option rendering inAlterTableandCreateTable, argument wrapping inExpression,In,OperatorandPredicateSet, join names inAbstractSql::processJoin(), and column aliases and order direction inSelect.where()andhaving()setters,Insert::values(), the bound-parameter loops inInsertandUpdate,Select::group()andSelect::order(), andAbstractSql::resolveTable().AbstractSqlgains a privatequoteJoinTableIdentifier(), soprocessJoin()'smatchstays flat.TableIdentifierwithout a schema, andresolveTable()with a null or empty table. Neither path had a test.src/Sqlentries change.Breaking changes
None.
mago format,mago lint,mago analyzeand the unit tests pass, and every changed line is covered.