Skip to content

Commit 47855dc

Browse files
authored
fix: cannot copy filter values which are enum (#49)
1 parent cea26aa commit 47855dc

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,4 @@ db.updatePartial("Collection", user1.id, Map.of("lastName", "UpdatedPartially"),
235235

236236
db.find("Collection1", cond, "Partition1");
237237
```
238+

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.github.thunderz99</groupId>
55
<artifactId>java-cosmos</artifactId>
66
<packaging>jar</packaging>
7-
<version>0.2.25</version>
7+
<version>0.2.26</version>
88
<name>${project.groupId}:${project.artifactId}$</name>
99
<description>A lightweight Azure CosmosDB client for Java</description>
1010
<url>https://github.com/thunderz99/java-cosmos</url>

src/main/java/io/github/thunderz99/cosmos/condition/Condition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ Object copyValue(Object value) {
822822
}
823823

824824
// primitive type
825-
if (value instanceof String || Primitives.isWrapperType(value.getClass()) || value.getClass().isPrimitive()) {
825+
if (value instanceof String || Primitives.isWrapperType(value.getClass()) || value.getClass().isPrimitive() || value.getClass().isEnum()) {
826826
return value;
827827
}
828828

src/test/java/io/github/thunderz99/cosmos/condition/ConditionTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,21 @@ public void copy_should_work_for_rawsql() {
749749
}
750750
}
751751

752+
public enum Status {
753+
enrolled, suspended, retired
754+
}
755+
756+
@Test
757+
public void copy_should_work_for_enum() {
758+
759+
var cond = Condition.filter("id", "ID001", "status", Status.enrolled);
760+
761+
var copy = cond.copy();
762+
assertThat(copy.filter.get("id")).isEqualTo("ID001");
763+
assertThat(copy.filter.get("status")).isEqualTo(Status.enrolled);
764+
765+
}
766+
752767
@Test
753768
public void buildQuerySpec_should_work_for_is_defined() {
754769

0 commit comments

Comments
 (0)