Skip to content

PostgreSQL/SQL Server利用時、SelectValueプロパティをソート条件にdistinctして検索するとSQL例外が発生する - #2174

Merged
yuichi-github merged 2 commits into
masterfrom
feature/2160-distinct-orderby-select-property
Jul 29, 2026
Merged

PostgreSQL/SQL Server利用時、SelectValueプロパティをソート条件にdistinctして検索するとSQL例外が発生する#2174
yuichi-github merged 2 commits into
masterfrom
feature/2160-distinct-orderby-select-property

Conversation

@HiguchiKiyoshi

Copy link
Copy Markdown
Member

closes #2160

対応内容

PostgreSQL/SQL Server利用時、
SelectValueプロパティをソート条件にdistinctして検索する場合に、
当該SelectValueのorder by に指定したCASE文をselect項目に追加する。

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

本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を追加(抽象メソッド)

@HiguchiKiyoshi
HiguchiKiyoshi requested a review from hkondoh July 28, 2026 06:23
@yuichi-github
yuichi-github merged commit cffbab2 into master Jul 29, 2026
5 checks passed
@yuichi-github
yuichi-github deleted the feature/2160-distinct-orderby-select-property branch July 29, 2026 00:43
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.

PostgreSQL/SQL Server利用時、SelectValueプロパティをソート条件にdistinctして検索するとSQL例外が発生する

4 participants