Skip to content

Commit

Permalink
Consider supporting count query method keyword
Browse files Browse the repository at this point in the history
Closes gh-20
  • Loading branch information
DAN1X27 authored and evgeniycheban committed Dec 27, 2024
1 parent 849ca05 commit 32b0b78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public Object execute(Object[] parameters) {
if (this.tree.isExistsProjection()) {
return query.exists();
}
if (this.tree.isCountProjection()) {
return query.count();
}
return query.findOne();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,14 @@ public void existsByName() {
assertTrue(this.repository.existsByName(testItem.getName()));
}

@Test
public void countByValue() {
this.repository.save(new TestItem(1L, "TestName1", "TestValue"));
this.repository.save(new TestItem(2L, "TestName2", "TestValue"));
this.repository.save(new TestItem(3L, "TestName3", "TestValue1"));
assertEquals(2, this.repository.countByValue("TestValue"));
}

@Test
public void findByEnumStringIn() {
List<TestItem> expectedItems = new ArrayList<>();
Expand Down Expand Up @@ -837,6 +845,8 @@ Optional<TestItem> findOneSqlByNameAndValueManyParams(String name1, String name2
List<TestItem> findByTestEnumOrdinalIn(TestEnum... values);

boolean existsByName(String name);

int countByValue(String name);
}

@Namespace(name = NAMESPACE_NAME)
Expand Down

0 comments on commit 32b0b78

Please sign in to comment.