Skip to content

fix: EXPOSED-1040 Support SELECT without FROM table clause - #2902

Merged
Leonid Stashevsky (e5l) merged 2 commits into
mainfrom
e5l/select-expression
Sep 29, 2026
Merged

Leonid Stashevsky (e5l) merged 2 commits into
mainfrom
e5l/select-expression

Conversation

@e5l

Copy link
Copy Markdown
Member

Description

Introduce select expression which allows to use select statement without column set.


Type of Change

Please mark the relevant options with an "X":

  • Bug fix
  • New feature
  • Documentation update

Updates/remove existing public API methods:

  • Is breaking change

Affected databases:

  • MariaDB
  • Mysql5
  • Mysql8
  • Oracle
  • Postgres
  • Redshift
  • SqlServer
  • H2
  • SQLite

Checklist

  • Unit tests are in place
  • The build is green (including the Detekt check)
  • All public methods affected by my PR has up to date API docs
  • Documentation for my change is up to date

Related Issues

EXPOSED-1040 Support SELECT without FROM table clause

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for “tableless” SELECT statements (i.e., SELECT 1 without an explicit FROM) across Exposed’s JDBC and R2DBC APIs, including convenience terminals for fetching a single projected value and documentation/tests to lock in the behavior.

Changes:

  • Introduces top-level tableless select(...) overloads (JDBC + R2DBC) backed by Table.Dual, plus selectValue(...) terminals.
  • Adds a generic literal(value) helper in exposed-core for wrapping common scalar Kotlin/Java values as SQL literals, plus tests.
  • Updates user documentation and changelog; refreshes SQL Server docker image tag used in dev/test infra.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
exposed-tests/src/test/kotlin/org/jetbrains/exposed/v1/tests/shared/types/LiteralOpTests.kt New tests for literal(value) type resolution, decimal precision/scale, and unsupported types.
exposed-tests/src/test/kotlin/org/jetbrains/exposed/v1/tests/shared/dml/SelectExpressionTest.kt New JDBC tests covering tableless selects, selectValue, set ops, derived table usage, and edge cases.
exposed-tests/src/test/kotlin/org/jetbrains/exposed/v1/tests/shared/dml/DualTableTest.kt Removes old Table.Dual-focused test, superseded by tableless select tests.
exposed-r2dbc/src/main/kotlin/org/jetbrains/exposed/v1/r2dbc/Queries.kt Adds tableless select(...) overloads and suspending selectValue(...) terminals for R2DBC.
exposed-r2dbc/api/exposed-r2dbc.api Public API surface update for the new R2DBC query helpers.
exposed-r2dbc-tests/src/test/kotlin/org/jetbrains/exposed/v1/r2dbc/sql/tests/shared/dml/SelectExpressionTest.kt New R2DBC tests validating tableless select and selectValue behavior.
exposed-r2dbc-tests/src/test/kotlin/org/jetbrains/exposed/v1/r2dbc/sql/tests/shared/dml/DualTableTest.kt Removes old R2DBC Table.Dual test, superseded by tableless select tests.
exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/v1/jdbc/Queries.kt Adds tableless select(...) overloads and selectValue(...) terminals for JDBC.
exposed-jdbc/api/exposed-jdbc.api Public API surface update for the new JDBC query helpers.
exposed-core/src/main/kotlin/org/jetbrains/exposed/v1/core/LiteralOp.kt Adds literal(value) auto-resolver for common scalar types (+ UUID support).
exposed-core/src/main/kotlin/org/jetbrains/exposed/v1/core/BinaryLiteralColumnType.kt Internal column type to render ByteArray literals using blob/hex formatting rules.
exposed-core/api/exposed-core.api Public API surface update for the new literal(value) function.
documentation-website/Writerside/topics/DSL-Querying-data.topic Adds a “Tableless SELECT queries” documentation chapter with examples and caveats.
CHANGELOG.md Adds feature entry describing tableless select + selectValue + literal.
buildScripts/docker/docker-compose-sqlserver.yml Updates SQL Server container image tag.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread exposed-core/src/main/kotlin/org/jetbrains/exposed/v1/core/LiteralOp.kt Outdated

@bog-walk Chantal Loncle (bog-walk) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also check failing tests on some db?

Comment thread CHANGELOG.md Outdated
Comment thread documentation-website/Writerside/topics/DSL-Querying-data.topic Outdated
Comment thread documentation-website/Writerside/topics/DSL-Querying-data.topic
Comment thread documentation-website/Writerside/topics/DSL-Querying-data.topic
Comment thread exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/v1/jdbc/Queries.kt Outdated
Comment thread exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/v1/jdbc/Queries.kt Outdated
Comment thread exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/v1/jdbc/Queries.kt Outdated

@bog-walk Chantal Loncle (bog-walk) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Minor comments to check. Please also rebase to fix refactoring merge conflict.

*
* Some queries without a `FROM` clause are valid, such as `select(intLiteral(1))`. Others are not. For example,
* Others are not. For example,
* `select(MyTable.id)` is rejected by the database during execution because `MyTable` is not a query source.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate KDocs line

Comment on lines +61 to +65
* ```kotlin
* val one = intLiteral(1)
* val status = stringLiteral("ready")
* val result = select(listOf(one, status)).single()
* ```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if KDocs was similar to the one for function above, stating what the SQL would be:

For instance SELECT 1, 'ready' can be written as follows:

Comment on lines +51 to +55
* ```kotlin
* val one = intLiteral(1)
* val status = stringLiteral("ready")
* val result = select(listOf(one, status)).single()
* ```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for same file in exposed-jdbc

<chapter id="tableless-select-limitations">
<title>Limitations</title>
<p>
A tableless <code>SELECT</code> have some database limitations:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: 'have' -> 'has'

@e5l
Leonid Stashevsky (e5l) merged commit 80f98e7 into main Sep 29, 2026
14 checks passed
@e5l
Leonid Stashevsky (e5l) deleted the e5l/select-expression branch September 29, 2026 11:26
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.

3 participants