File tree Expand file tree Collapse file tree
it/java/io/weaviate/integration
main/java/io/weaviate/client6/v1/api/collections/data Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -468,6 +468,12 @@ public void testDataTypes() throws IOException {
468468
469469 }
470470
471+ record Address (
472+ String street ,
473+ @ io .weaviate .client6 .v1 .api .collections .annotations .Property ("building_nr" ) int buildingNr ,
474+ @ io .weaviate .client6 .v1 .api .collections .annotations .Property ("isOneWay" ) boolean oneWay ) {
475+ }
476+
471477 @ Test
472478 public void testNestedProperties_insertMany () throws IOException {
473479 // Arrange
@@ -486,10 +492,10 @@ public void testNestedProperties_insertMany() throws IOException {
486492 "street" , "Burggasse" ,
487493 "building_nr" , 51 ,
488494 "isOneWay" , true ));
489- Map <String , Object > house_2 = Map .of ("address" , Map . of (
490- "street" , " Port Mariland St." ,
491- "building_nr" , 111 ,
492- "isOneWay" , false ));
495+ Map <String , Object > house_2 = Map .of ("address" , new Address (
496+ "Port Mariland St." ,
497+ 111 ,
498+ false ));
493499
494500 // Act
495501 var result = buildings .data .insertMany (house_1 , house_2 );
Original file line number Diff line number Diff line change @@ -293,6 +293,20 @@ private static com.google.protobuf.Value marshalValue(Object value) {
293293 protoNested .putFields ((String ) nested .getKey (), nestedValue );
294294 });
295295 protoValue .setStructValue (protoNested );
296+ } else if (value instanceof Record r ) {
297+ @ SuppressWarnings ("unchecked" )
298+ CollectionDescriptor <? super Record > recordDescriptor = (CollectionDescriptor <? super Record >) CollectionDescriptor
299+ .ofClass (r .getClass ());
300+ var protoRecord = com .google .protobuf .Struct .newBuilder ();
301+ recordDescriptor .propertiesReader (r ).readProperties ().entrySet ().stream ()
302+ .forEach (recordField -> {
303+ var nestedValue = marshalValue (recordField .getValue ());
304+ if (nestedValue == null ) {
305+ return ;
306+ }
307+ protoRecord .putFields ((String ) recordField .getKey (), nestedValue );
308+ });
309+ protoValue .setStructValue (protoRecord );
296310 } else {
297311 throw new IllegalArgumentException ("data type " + value .getClass () + " is not supported" );
298312 }
You can’t perform that action at this time.
0 commit comments