Skip to content

feat: share one row record per table across full-row queries - #27

Merged
omer-cengel merged 2 commits into
masterfrom
feature/shared-table-row-records
Sep 24, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
feature/shared-table-row-records

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

Queries that return one complete table row now return a reusable nested <Table>Row record in their repository instead of a separate per-query result record. Create, read, and list operations on the same table therefore share one Java type, such as AuthorRepository.AuthorsRow, and application code no longer converts between identical per-query records.

Changes

  • A SELECT with exactly one source whose only projection item is * or <source>.*, and an INSERT, UPDATE, or DELETE whose RETURNING clause is exactly *, return the repository's <Table>Row record. Aliases and table-name spelling in the query do not affect which row type is used.
  • Each such table gets one nested public record <Table>Row in schema column order, with lower-camel-case components (for example createdAt), and one private positional row mapper. Both are generated once, after the repository constructor, in the order queries first use them.
  • Row names are normalized from the table name and never singularized, so authors generates AuthorsRow and authorsRowMapper. A row mapper yields to a query's own mapper with a numeric suffix, so a query named Authors keeps authorsRowMapper and the row mapper becomes authorsRowMapper1. Method parameters avoid all row-mapper names.
  • Two tables in one repository whose row types are equal ignoring case are rejected before any file is written, naming both tables and both types.
  • The Maven/PostgreSQL sample now uses RETURNING * and SELECT *, so createAuthor, getAuthor, and listAuthors all return AuthorRepository.AuthorsRow. The README, quickstart, query, and configuration documentation describe the rule, naming, and collisions.
  • Analyzer, generator, compile, and PostgreSQL integration tests cover shared and per-table row records, mapper disambiguation, and the collision error.

Scope and non-goals

  • Explicit column lists (even ones naming every column), a wildcard combined with another projection item, wildcards in joins, and RETURNING column lists keep their query-specific <Query>Result records, with unchanged alias naming and selected-column order.
  • Method parameter order and JDBC binding order are unchanged.
  • Query cardinality, null semantics, the runtime executor, RETURNING aliases, structural deduplication of result records, and configuration options are unchanged.

A query whose only projection is a single-source SELECT * or
SELECT <source>.*, or whose RETURNING clause is exactly *, now returns the
repository's nested <Table>Row record instead of its own <Query>Result.
Each table gets one row record, in schema column order, and one positional
row mapper, generated after the constructor in first-use order and shared
by every such query.

Explicit column lists, a wildcard combined with another item, wildcards in
joins, and RETURNING column lists keep their query-specific records. A row
mapper yields to a query's own mapper name with a numeric suffix, and two
tables whose row types are equal ignoring case are rejected before any file
is written. Parameter and binding order are unchanged.
@omer-cengel
omer-cengel merged commit 1b4648e into master Sep 24, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the feature/shared-table-row-records branch September 24, 2026 20:21
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