Skip to content

Postgres features + extensibility: RETURNING, ON CONFLICT variants, CTEs, lateral joins, expression rendering, infix-operator registry#130

Merged
JordanMarr merged 2 commits into
JordanMarr:beta-4.1from
michaelglass:feature/postgres-extension-v4
Jun 9, 2026
Merged

Postgres features + extensibility: RETURNING, ON CONFLICT variants, CTEs, lateral joins, expression rendering, infix-operator registry#130
JordanMarr merged 2 commits into
JordanMarr:beta-4.1from
michaelglass:feature/postgres-extension-v4

Conversation

@michaelglass

Copy link
Copy Markdown
Contributor

Second (and final) PR from #125, following #129. All additive; two commits: features, then the extensibility seam that builds on them.

New CE operations: returning (insert/update/delete), fromSelect, setRaw,
whereExists/whereNotExists, havingRaw, orderByRaw/orderByAlias(/Desc),
nullsFirst/nullsLast, distinctOn, lateralJoin, and ON CONFLICT variants (composable
onConflictdoNothing/doUpdate/doUpdateCoalesce, raw targets, partial-index WHERE).

New functions: caseWhen/caseWhenMulti, castAs<'T>, countDistinct, cte/cteFrom,
rawExpr, lateralCol, inlineValue, greatest/least, interval.

Expression rendering: arithmetic + method calls in select/orderBy projections (with
parameter binding), anonymous-record AS aliases (incl. an ExpressionNormalizer fix for
renamed fields), aggregates over Option-wrapped (leftJoin') columns, scalar function names
emitted uppercase.

IR: LeftJoinLateral, NullsOrdering, parameterized OrderByRaw/RawColumn,
Exists/NotExists, DistinctOn, Returning, conflict variants.

Extensibility (2nd commit): SqlHydraInfixOperatorAttribute + an InfixOperators registry —
external packages register SQL infix operators via an assembly attribute, auto-discovered on
first query compile. Registered 2-arg functions render as infix in select/orderBy/where. Plus a
public tryGetOrderByColumn helper so extension packages can resolve orderBy column selectors
without internals access.

16 files, +2028/−194 — 43 new unit tests (every new op asserts its emitted SQL), validated
against ~1,100 real queries in a private project.

Together these unblock https://github.com/michaelglass/SqlHydra.Query.Pgvector.

Developed with AI assistance.

michaelglass and others added 2 commits June 7, 2026 19:34
…CONFLICT, CTEs, lateral joins, expression rendering

Adds: returning/fromSelect/setRaw/whereExists/whereNotExists/havingRaw,
orderByRaw/orderByAlias(Desc), nullsFirst/nullsLast, distinctOn, lateralJoin,
composable ON CONFLICT (onConflict/doNothing/doUpdate/doUpdateCoalesce, raw
targets, partial-index WHERE); caseWhen/caseWhenMulti, castAs, countDistinct,
cte/cteFrom, rawExpr, lateralCol, inlineValue, greatest/least, interval;
expression rendering for arithmetic/method-call projections with parameter
binding; anonymous-record AS aliases (incl. ExpressionNormalizer fix for
renamed fields); aggregates over Option-wrapped (leftJoin') columns; scalar
function names emitted uppercase. 42 new unit tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…l packages (e.g. pgvector)

Adds SqlHydraInfixOperatorAttribute + an InfixOperators registry (assembly
scan on first query compile, AssemblyLoad subscription for lazy plugins,
manual register for tests) and recognizes registered 2-arg functions as infix
operators in select/orderBy/where expression rendering. InternalsVisibleTo
for the SqlHydra.Query.Pgvector package. Tests cover both the manual-register
and the assembly-attribute auto-discovery paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@michaelglass michaelglass force-pushed the feature/postgres-extension-v4 branch from be9eb97 to 565f2de Compare June 7, 2026 17:37
@JordanMarr JordanMarr changed the base branch from main to beta-4.1 June 9, 2026 03:07
@JordanMarr JordanMarr merged commit 3f7da41 into JordanMarr:beta-4.1 Jun 9, 2026
1 check passed
@JordanMarr

Copy link
Copy Markdown
Owner

Merged to beta-4.1 branch and published as 4.1.0-beta.1!

JordanMarr added a commit that referenced this pull request Jun 10, 2026
…y sites

Forward-ports the issue #134 parameter-collision fix from main. Kept beta's
4.1.0-beta.1 version (discarded main's 4.0.2 bump) and extended the shared
EmitSelectInto fix to the subquery sites PR #130 added on this branch, which
carried the identical fresh-collector-then-merge bug:
  - Exists / NotExists
  - WITH / CTEs
  - JOIN / lateral-join subqueries
  - INSERT ... FROM SELECT

All 260 unit tests pass (incl. #130's 43 new tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JordanMarr

Copy link
Copy Markdown
Owner

@michaelglass FYI, there was a bug #134 that affected the main branch (released as v4.0.2) which has also been merged into beta-4.1 branch.

@michaelglass michaelglass deleted the feature/postgres-extension-v4 branch June 10, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants