Skip to content

feat(analysis): name RETURNING columns from their aliases - #74

Merged
omer-cengel merged 1 commit into
masterfrom
feature/aliased-returning-items
Oct 11, 2026
Merged

omer-cengel merged 1 commit into
masterfrom
feature/aliased-returning-items

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

A RETURNING column on INSERT, UPDATE, or DELETE can now carry an alias that names its generated result component, the same way a SELECT item's alias does. Previously every aliased RETURNING item was rejected, so a returning write could not choose its result component names.

Changes

  • A returned direct column written as id AS user_id, id user_id, a quoted alias such as id AS "User Id", or a column qualified through the target's alias such as u.id AS uid is named by its alias. Its Java type, nullability, enum, and array facts still come from the schema column.
  • A returned column list, aliased or not, keeps the query's own <QueryName>Result record. Only a bare, unaliased RETURNING * returns the table's shared <TableName>Row record.
  • An aliased wildcard (RETURNING * AS x or RETURNING * x) is rejected as RETURNING * must not be aliased..
  • Parameter order, binding order, selected-column order, and the executed SQL, including the alias text, are unchanged.
  • Analyzer tests cover each write statement and alias spelling. A compiler test compiles a generated repository with alias-named components, and a PostgreSQL test reads aliased components from executed returning writes.
  • The query documentation describes the accepted alias forms and the remaining rejections.

Scope and non-goals

  • Computed or cast RETURNING items stay rejected with or without an alias, as does a qualified table.* with or without an alias.
  • No changes to Java generation or the runtime. Aliased returned columns flow through the existing result-column naming and positional row mapping.

A returned direct column on INSERT, UPDATE, or DELETE may now carry an
alias, written with or without AS, which names its result component as a
SELECT item's alias does; its type and nullability still come from the
schema column. An aliased bare * is rejected as "RETURNING * must not be
aliased.", and computed items stay rejected with or without an alias.
@omer-cengel
omer-cengel merged commit 4da43cd into master Oct 11, 2026
7 checks passed
@omer-cengel
omer-cengel deleted the feature/aliased-returning-items branch October 11, 2026 14:35
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.

1 participant