Skip to content

Commit

Permalink
#3490 filterMany generates invalid sql when the many side uses @Embed…
Browse files Browse the repository at this point in the history
…dedId to model composite primary key
  • Loading branch information
rbygrave committed Oct 10, 2024
1 parent 45cc78b commit 8e627c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class DataWithFormula {
@ManyToOne
private DataWithFormulaMain main;

// @Index
// private String stringValue;
public DataWithFormulaKey getId() {
return id;
}
Expand All @@ -39,10 +37,4 @@ public Integer getValueIndex() {
public void setValueIndex(Integer valueIndex) {
this.valueIndex = valueIndex;
}
// public String getStringValue() {
// return stringValue;
// }
// public void setStringValue(String stringValue) {
// this.stringValue = stringValue;
// }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.querytest;

import io.ebean.DB;
import io.ebean.test.LoggedSql;
import org.example.domain.DataWithFormulaMain;
import org.example.domain.query.QDataWithFormulaMain;
import org.junit.jupiter.api.Test;

Expand All @@ -21,6 +23,19 @@ void testFilterMany() {
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains(" where ((t1.main_id is null and t1.meta_key is null and t1.value_index is null) or (t1.meta_key = ?)) order by t0.id");
}

@Test
void testFilterManyComposite() {
LoggedSql.start();

DB.find(DataWithFormulaMain.class)
.where()
.filterMany("metaData").eq("metaKey", "")
.findList();

List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains(" where ((t1.main_id is null and t1.meta_key is null and t1.value_index is null) or (t1.meta_key = ?)) order by t0.id");
}
}

0 comments on commit 8e627c7

Please sign in to comment.