-
Notifications
You must be signed in to change notification settings - Fork 132
#30 - Add custom conversion support to write array-typed values. #31
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
Conversation
EntityRowMapper now passes-thru values for Collection-like types such as array. Arrays are supported by Postgres. Original pull request: #22.
Add author tag. Add unit test for EntityRowMapper.
We now support custom conversions via R2dbcCustomConversions. Custom conversions introduces simple types that depend on the used dialect. Custom conversions and simple types are held in RelationalConverter and MappingContext. Simple types and conversions are used by DatabaseClient and repository support to properly apply registered converters and support native types such as array-columns. Related tickets: #22, #26.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I found a couple of things that should work, but don't.
I'd also like to see some integration tests for the database(s) that support arrays.
src/main/java/org/springframework/data/r2dbc/dialect/PostgresDialect.java
Outdated
Show resolved
Hide resolved
src/test/java/org/springframework/data/r2dbc/dialect/PostgresDialectUnitTests.java
Show resolved
Hide resolved
src/test/java/org/springframework/data/r2dbc/function/convert/EntityRowMapperUnitTests.java
Show resolved
Hide resolved
src/test/java/org/springframework/data/r2dbc/function/convert/EntityRowMapperUnitTests.java
Show resolved
Hide resolved
Minor formatting. Add suggestions. Update src/test/java/org/springframework/data/r2dbc/dialect/PostgresDialectUnitTests.java Co-Authored-By: mp911de <[email protected]>
I applied your suggestions @schauder and pushed the improvements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I found one more corner case that should get proper handling.
Plus small stuff.
src/main/java/org/springframework/data/r2dbc/dialect/PostgresDialect.java
Outdated
Show resolved
Hide resolved
ArrayColumns arrayColumns = PostgresDialect.INSTANCE.getArraySupport(); | ||
|
||
assertThatThrownBy(() -> arrayColumns.getArrayType(getClass())).isInstanceOf(IllegalArgumentException.class); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
@Test // gh-30 | |
public void shouldRejectNestedCollections() { | |
ArrayColumns arrayColumns = PostgresDialect.INSTANCE.getArraySupport(); | |
assertThatThrownBy( | |
() -> arrayColumns.getArrayType(List.class) | |
).isInstanceOf(IllegalArgumentException.class); | |
} |
The added test fails but I think it should because we don't apply the conversion to arrays recursively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add the test and remove List
from simple types. While Postgres supports n-dimensional array, the driver does not support that option so it's safe for now to only support 1-dimensional arrays without recursion.
src/test/java/org/springframework/data/r2dbc/dialect/PostgresDialectUnitTests.java
Outdated
Show resolved
Hide resolved
Introduce ArrayColumns type to encapsulate Dialect-specific array support. Apply array conversion for properties that do not match the native array type. Add integration tests for Postgres array columns.
Add author tag. Add unit test for EntityRowMapper. Original pull request: #31.
We now support custom conversions via R2dbcCustomConversions. Custom conversions introduces simple types that depend on the used dialect. Custom conversions and simple types are held in RelationalConverter and MappingContext. Simple types and conversions are used by DatabaseClient and repository support to properly apply registered converters and support native types such as array-columns. Related tickets: #22, #26. Original pull request: #31.
Minor formatting. Add suggestions. Update src/test/java/org/springframework/data/r2dbc/dialect/PostgresDialectUnitTests.java Co-Authored-By: mp911de <[email protected]> Original pull request: #31.
Introduce ArrayColumns type to encapsulate Dialect-specific array support. Apply array conversion for properties that do not match the native array type. Add integration tests for Postgres array columns. Original pull request: #31.
Merged. |
We now support custom conversions via R2dbcCustomConversions. Custom conversions introduces simple types that depend on the used dialect. Custom conversions and simple types are held in RelationalConverter and MappingContext.
Simple types and conversions are used by DatabaseClient and repository support to properly apply registered converters and support native types such as array-columns.
Supersedes PR #22.
Related tickets: #22, #26, #30.