feat(psql): multiple FROM/USING sources, join chains, and table functions#690
Merged
stephenafamo merged 1 commit intoMay 21, 2026
Merged
Conversation
Owner
|
This is a fantastic PR. Thank you. Seems there are a few lint issues to fix though |
…e typing Support variadic FROM/USING with inline joins, table functions, JoinChain[Q Joinable], and AppendJoin on the last from_item for UPDATE/DELETE queries.
e9f7070 to
f91d49b
Compare
Contributor
Author
Done. I think this will be my last PR for a while, now we just wait for the release :) |
Owner
|
Released |
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.
This is a reworked version resulting from #689
Extends the PostgreSQL query builder for
UPDATE ... FROMandDELETE ... USINGso multiple comma-separatedfrom_itemsources are supported, with inline and standalone joins, table functions, and matchingbobgen-psqlcodegen.UPDATE / DELETE
FROM/USINGsources live inUpdateQuery.FromItemsandDeleteQuery.UsingItems(not the embeddedTableRefon the query struct).um.Table(...)/dm.From(...); extra sources useum.From(...)/dm.Using(...).um.From(...)ordm.Using(...)call appends one comma-separatedfrom_item(repeated calls builda, b, (c JOIN d)).um.From(table, joins...)anddm.Using(table, joins...)accept optionalJoinChainarguments (InnerJoin,LeftJoin,CrossJoin, etc.) on that source.um.InnerJoin,dm.LeftJoin, …) attach to the lastfrom_itemwhenFromItems/UsingItemsis non-empty.from_itemhas joins and more items follow, the writer parenthesizes it (PostgreSQL: comma binds looser thanJOIN).Table functions
um.FromFunction,dm.UsingFunction, andsm.FromFunctionreturnbob.Expression(single function orROWS FROM (...)for multiple).um.From/dm.Using/sm.From; aliasing and table modifiers stay on theFrom/Usingchain (.As(...),.Only(), etc.).SELECT (related)
sm.FromFunctionno longer returnsFromChainor appliesFROMby itself — usesm.From(sm.FromFunction(...)).sm.FromusesAppendTableRef(replace semantics); fixes stale alias when replacingFROMwithout a new alias..On(),.Using(),.Natural(), …) returnJoinChainfor fluent chaining instead ofbob.Mod.CrossJoinis unified underJoinChain(no separateCrossJoinChain).Codegen
bobgen-psqlparses multipleUPDATE ... FROM/DELETE ... USINGitems and emitsAppendTableRef(...)per item; column resolution considers every source.Breaking changes
UPDATE/DELETEextra sources moved from embeddedclause.TableReftoFromItems/UsingItems; useum.Table/dm.Fromfor the target table.um.FromFunction/sm.FromFunctionreturnbob.Expressionand must be wrapped inFrom/Using.um/dmjoin helpers returnJoinChain[*UpdateQuery]/JoinChain[*DeleteQuery];.On(),.Using(), etc. returnJoinChaininstead ofbob.Mod.Examples