Skip to content

Commit

Permalink
issue fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anidotnet committed Jul 1, 2024
1 parent 86cd229 commit 5132886
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Release 4.3.1

### Issue Fixes

- Fix for `Document.getFields()` not returning iterable fields

## Release 4.3.0 - Jul 1, 2024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ private Set<String> getFieldsInternal(String prefix) {
// ignore the reserved fields
if (reservedFields.contains(entry.getFirst())) continue;

if (isNullOrEmpty(entry.getFirst())) continue;

Object value = entry.getSecond();
if (value instanceof NitriteDocument) {
// if the value is a document, traverse its fields recursively,
Expand All @@ -278,7 +280,7 @@ private Set<String> getFieldsInternal(String prefix) {
fields.addAll(((NitriteDocument) value).getFieldsInternal(prefix
+ NitriteConfig.getFieldSeparator() + entry.getFirst()));
}
} else if (!(value instanceof Iterable)) {
} else {
// if there is no more embedded document, add the field to the list
// and if this is an embedded document then prefix its name by parent fields,
// separated by field separator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,15 @@ public void testRemoveFromArray() {
@Test
public void getFields() {
Set<String> fields = doc.getFields();
assertEquals(fields.size(), 5);
assertEquals(fields.size(), 8);
assertTrue(fields.contains("location.address.line1"));
assertTrue(fields.contains("location.address.line2"));
assertTrue(fields.contains("location.address.house"));
assertTrue(fields.contains("location.city"));
assertTrue(fields.contains("location.state"));
assertTrue(fields.contains("score"));
assertTrue(fields.contains("objArray"));
assertTrue(fields.contains("category"));
}

@Test
Expand Down

0 comments on commit 5132886

Please sign in to comment.