Open
Description
I have a table where the field is desc
. Since it's a reserved keyword in PostgreSQL, I had to use the annotation @Column("\"desc\"")
to allow it to be written properly. However, when reading the data, I found that it cannot be read correctly because in org.springframework.data.relational.core.conversion.MappingRelationalConverter#read
, the org.springframework.data.relational.core.conversion.RowDocumentAccessor#hasValue
method doesn't recognize the field. I believe some logic should be added here to solve this issue.
Activity
[-]MappingR2dbcConverter cannot convert reserved keyword fields[/-][+]MappingRelationalConverter cannot convert reserved keyword fields[/+]ShenFeng312 commentedon Feb 17, 2025
can we add a annotation like
@ResultSetKey("desc")
or other way to support it @mp911de @schauderschauder commentedon Feb 17, 2025
With
@Column("\"desc\"")
you make the double quotes part of the column name. Is that intended? SQL identifier in@Column
,@Table
and similar annotations are used exactly as they are given, and properly quoted to avoid interpretation as key words, or automatic changes to upper or lower case.Therefore I guess you really want to use
@Column("desc")
.If that still doesn't work, please provide a full reproducer, preferably base on https://github.com/schauder/issue-jdbc-1993
ShenFeng312 commentedon Feb 18, 2025
@schauder Thank you for your help, and sorry I forgot to mention that this bug occurs under
r2dbc
. I tried using the demo provided in your repository for testing, but I’m not sure how to useTestcontainersConfiguration
. I believe when usingr2dbc
, saving data causes an error. The logs I printed indicate that it is not treating field and table names as keywords.ShenFeng312 commentedon Feb 18, 2025
The cause of the bug seems to be that the default values provided by
org.springframework.data.r2dbc.mapping.R2dbcMappingContext
are inconsistent with JDBC. Should I submit a PR to fix this issue?mp911de commentedon Feb 18, 2025
We initially didn't want to enable
forceQuote
for R2DBC to retain compatibility. It would make sense to align for the next major revision, so feel free to submit a pull request. I assume that updating all tests will be the major effort here.[-]MappingRelationalConverter cannot convert reserved keyword fields[/-][+]Use force-quoting in `R2dbcMappingContext` by default[/+]10 remaining items