From f8964707d919bbbfc2cb6e9432fd8ac45f058beb Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 27 Aug 2024 21:01:51 +1200 Subject: [PATCH] #3463 - Ignore queryBean.select(null) calls (#3464) --- .../server/querydefn/DefaultOrmQuery.java | 4 +++- .../src/test/java/org/querytest/QOrderTest.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java index 5bb3b60279..097c2fc333 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java @@ -1367,7 +1367,9 @@ public final Query select(String columns) { @Override public final Query select(FetchGroup fetchGroup) { - this.detail = ((SpiFetchGroup) fetchGroup).detail(); + if (fetchGroup != null) { + this.detail = ((SpiFetchGroup) fetchGroup).detail(); + } return this; } diff --git a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java index 1eec44f2ad..7f9beba1e0 100644 --- a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java +++ b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java @@ -142,6 +142,22 @@ void fetchCache() { .findList(); } + @Test + void viaNullFetchGraph() { + DB.getDefault(); + LoggedSql.start(); + + FetchGroup fg = null; + new QOrder() + .select(fg) + .status.eq(Order.Status.NEW) + .findList(); + + final List sql = LoggedSql.stop(); + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("select /* QOrderTest.viaNullFetchGraph */ t0.id, "); + } + @Test void viaFetchGraph() {