PostgreSQL/SQL Server利用時、SelectValueプロパティをソート条件にdistinctして検索するとSQL例外が発生する - #2174
Merged
yuichi-github merged 2 commits intoJul 29, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
本PRは、PostgreSQL/SQL Server で「SELECT DISTINCT + ORDER BY(SelectValueのソート用CASE式)」を含む検索を行った際に、ORDER BY 式が SELECT 句に含まれていないことで発生するSQL例外を回避するための対応です。RDBごとの要件差(DISTINCT時にORDER BY式自体をSELECTへ含める必要があるか)をフラグ化し、該当DBではソート用CASE式をSELECT句へ追加するようにしています。
Changes:
- RDBアダプタに「DISTINCT時にORDER BY式をSELECTへ含める必要があるか」を返す判定APIを追加(デフォルトfalse)。
- PostgreSQL/SQL Server アダプタで当該判定を true に設定。
- DISTINCTかつSelectValueソート時、対象プロパティが既にSELECT句に含まれている場合に限り、ORDER BY のCASE式をSELECT句へ追加(トップレベルクエリのみ)。
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| iplass-core/src/main/java/org/iplass/mtp/impl/rdb/sqlserver/SqlServerRdbAdapter.java | DISTINCT時にORDER BY式をSELECTへ含める必要があるDBとしてtrueを返す実装を追加 |
| iplass-core/src/main/java/org/iplass/mtp/impl/rdb/postgresql/PostgreSQLRdbAdapter.java | DISTINCT時にORDER BY式をSELECTへ含める必要があるDBとしてtrueを返す実装を追加 |
| iplass-core/src/main/java/org/iplass/mtp/impl/rdb/adapter/RdbAdapter.java | RDB差分判定API(デフォルトfalse)を追加 |
| iplass-core/src/main/java/org/iplass/mtp/impl/entity/VirtualPropertyAdapter.java | DISTINCT時のSelectValueソートにおけるORDER BY CASE式をSELECT句へ追加する変換ロジックを追加 |
| iplass-core/src/main/java/org/iplass/mtp/impl/datastore/grdb/GRdbDataStore.java | RdbAdapterの判定結果をDataStoreとして返せるように保持・公開 |
| iplass-core/src/main/java/org/iplass/mtp/impl/datastore/DataStore.java | DataStoreとして判定APIを追加(抽象メソッド) |
hkondoh
approved these changes
Jul 28, 2026
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.
closes #2160
対応内容
PostgreSQL/SQL Server利用時、
SelectValueプロパティをソート条件にdistinctして検索する場合に、
当該SelectValueのorder by に指定したCASE文をselect項目に追加する。