-
Notifications
You must be signed in to change notification settings - Fork 356
io.r2dbc.spi.Parameter
not considered a simple type
#1696
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
Comments
You need to apply casting on the SQL level. Alternatively, you can provide a converter from The driver doesn't provide any value objects for ranges, therefore you must bind the value as string and tell the driver to use R2DBC's Let me know whether this helps. |
Hey @mp911de, thanks for your swift reply. Ideally, I could avoid doing it on the SQL level and fully rely on the abstractions already there. Following your feedback, I tried the following (excuse the Kotlin): // Taken from PostgresTypes.from(...).lookupType("tsrange")
private val PG_RANGE_TYPE = PostgresTypes.PostgresType(3908, 3908, 3909, 3909, "tsrange", "R")
@WritingConverter
object TsRangeSerializer : Converter<TsRange, Parameter> {
override fun convert(source: TsRange): Parameter {
return Parameters.`in`(PG_RANGE_TYPE, source.toPostgresValue())
}
}
fun TsRange.toPostgresValue(): String =
"[\"${start.format(PG_TIMESTAMP_FORMATTER)}\",\"${end.format(PG_TIMESTAMP_FORMATTER)}\"]"
Unfortunately, now it fails with an error I don't fully comprehend:
I don't understand why it tries to bind to |
You could register a |
Maybe I'm misunderstanding something, but the value is not null in this case. The column itself is actually not nullable. That's why I expect it will never try to bind anything nullish. |
Can you provide the full stack trace and a minimal sample (SQL, domain types, converters, test)? Happy to debug the issue here once I have a bit of code that gets me started. |
Thank you! Here's the repo: https://github.com/rsmidt/spring-data-r2dbc-range-types It's written in Kotlin. I can change it to Java if required. It's expecting Postgres running on port 5432, configured in the application.properties (there's also a docker-compose.yml). Please let me know if I can help in any way. |
io.r2dbc.spi.Parameter
not considered a simple type
I moved this ticket into Spring Data Relational as Spring Data R2DBC is part of the Relational project. This is a bug where we attempt an entity conversion by extracting the identifier. |
We now consider R2DBC's Parameter as simple type to avoid entity handling. Closes #1696
We now consider R2DBC's Parameter as simple type to avoid entity handling. Closes #1696
That's fixed now. Care to upgrade to |
Stupid question, but where is the snapshot being published? If I try to override it like this:
It fails:
|
No worries, the repo is at <repository>
<id>spring-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/snapshot</url>
</repository> |
Yes! It's working now directly using the entity template. Thank you very much for the swift fix, it's much appreciated. |
I'm currently struggling to use a simple
tsrange
in a template entity insert.Reading is fine, as I can utilize a simple
Converter<String, MyTsRangeType>
. But doing the same for writing (Converter<MyTsRangeType, String>
) does not work:Is there a proper way for dealing with ranges?
The text was updated successfully, but these errors were encountered: