Skip to content

feat(object-mapping): Add support for mapping list value to array #1637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

injectives
Copy link
Contributor

@injectives injectives commented Apr 22, 2025

The main objective of this update is to add support for mapping list value to array. Given that org.neo4j.driver.Values#value(Object) method allows creating list value from array (excluding byte[]), it makes sense to support the mapping back from list value to array.

Example:

var array = new float[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
var values = Values.value(array);
assertArrayEquals(array, values.as(float[].class));

As org.neo4j.driver.Values#value(Object) supports mapping char[] and short[] to list values, the supported mappings from string and integer values have also been extended.

Updated list of supported mappings:

  • TypeSystem#LIST -> List, T[] as long as list elements may be mapped to the array component type (for example, char[], boolean[], String[], long[], int[], short[], double[], float[])
  • TypeSystem#STRING -> String, char, Character
  • TypeSystem#INTEGER -> long, Long, int, Integer, short, Short, double, Double, float, Float

@injectives injectives changed the title feat(object-mapping): Add support for mapping LIST Value to arrays feat(object-mapping): Add support for mapping LIST Value to array Apr 22, 2025
@injectives injectives force-pushed the feature/arrays branch 3 times, most recently from 8340e74 to 1bc0e00 Compare April 22, 2025 18:48
@injectives injectives changed the title feat(object-mapping): Add support for mapping LIST Value to array feat(object-mapping): Add support for mapping list value to array Apr 22, 2025
The main objective of this update is to add support for mapping list value to array. Given that `org.neo4j.driver.Values#value(Object)` method allows creating list value from array (excluding `byte[]`), it makes sense to support the mapping back from list value to array.

Example:
```java
var array = new float[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
var values = Values.value(array);
assertArrayEquals(array, values.as(float[].class));
```

As `org.neo4j.driver.Values#value(Object)` supports mapping `char[]` and `short[]` to list values, the supported mappings from string and integer values have also been extended.

Updated list of supported mappings:
- `TypeSystem#LIST` -> `List`, `T[]` as long as list elements may be mapped to the array component type (for example, `char[]`, `boolean[]`, `String[]`, `long[]`, `int[]`, `short[]`, `double[]`, `float[]`)
- `TypeSystem#STRING` -> `String`, `char`, `Character`
- `TypeSystem#INTEGER` -> `long`, `Long`, `int`, `Integer`, `short`, `Short`, `double`, `Double`, `float`, `Float`
Copy link

@MaxAake MaxAake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff!

@injectives injectives merged commit 17304b7 into neo4j:5.0 Apr 23, 2025
19 checks passed
@injectives injectives deleted the feature/arrays branch April 23, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants