Skip to content

Commit

Permalink
Merge 0c0a239 into 2bb3989
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 authored Oct 11, 2023
2 parents 2bb3989 + 0c0a239 commit 6cacb3f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/redis/clients/jedis/search/FieldName.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public FieldName as(String attribute) {
return this;
}

public final String getName() {
return name;
}

public final String getAttribute() {
return attribute;
}

public int addCommandArguments(List<Object> args) {
args.add(name);
if (attribute == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ public SchemaField as(String attribute) {
fieldName.as(attribute);
return this;
}

public final FieldName getFieldName() {
return fieldName;
}

public final String getName() {
return fieldName.getName();
}
}
16 changes: 16 additions & 0 deletions src/test/java/redis/clients/jedis/modules/search/UtilTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package redis.clients.jedis.modules.search;

import static org.junit.Assert.assertEquals;

import org.junit.Assert;
import org.junit.Test;

import redis.clients.jedis.search.RediSearchUtil;

import redis.clients.jedis.search.schemafields.NumericField;
import redis.clients.jedis.search.schemafields.SchemaField;

public class UtilTest {

@Test
Expand All @@ -13,4 +19,14 @@ public void floatArrayToByteArray() {
byte[] expected = new byte[]{-51, -52, 76, 62};
Assert.assertArrayEquals(expected, bytes);
}

@Test
public void getSchemaFieldName() {
SchemaField field = NumericField.of("$.num").as("num");

assertEquals("$.num", field.getFieldName().getName());
assertEquals("num", field.getFieldName().getAttribute());

assertEquals("$.num", field.getName());
}
}

0 comments on commit 6cacb3f

Please sign in to comment.