Skip to content
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

mysql keyword isn't mapping to the result #861

Closed
maple-seven opened this issue Jun 20, 2024 · 5 comments
Closed

mysql keyword isn't mapping to the result #861

maple-seven opened this issue Jun 20, 2024 · 5 comments

Comments

@maple-seven
Copy link

@Getter
@Setter
@Table("table")
public class SpotMarginUserSettingEntity {

    @Id
    private Long id;
    @Column("uid")
    private Long uid;
    @Column("`key`")
    private String key;
    @Column("value")
    private String value;
    @Column("created_at")
    private Instant createdAt;

}

The field key return null when query , if set the @column("key") it works fine ; but it'll error when insert or update because key is a keyword in mysql;

@maple-seven maple-seven changed the title mysql keyword is't mapping to the result mysql keyword isn't mapping to the result Jun 20, 2024
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 20, 2024
@mp911de
Copy link
Member

mp911de commented Jun 20, 2024

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem.
You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Jun 20, 2024
@maple-seven
Copy link
Author

java

@Getter
@Setter
@Table("demo")
public class Demo {
    @Id
    private Long id;
    @Column("uid")
    private Long uid;
    @Column("`key`")
    private String key;
    @Column("value")
    private String value;
    @Column("created_at")
    private Instant createdAt;
}

sql:

create table demo
(
    id         int unsigned auto_increment
        primary key,
    uid        bigint(11) unsigned default 0                 not null comment '',
    `key`      varchar(100)        default ''                not null comment '',
    value      varchar(100)        default ''                not null comment '',
    created_at datetime            default CURRENT_TIMESTAMP not null
);

INSERT INTO demo (uid, `key`, value) VALUES (10000, 'key1', '0');

query:

public interface SpotMarginUserSettingReadRepository extends R2dbcRepository<Demo, Long> {

    @Query("select * from demo where `key`= 'key1' and uid = :uid limit 1")
    Mono<Demo> getSomeDemo(long uid);
}

the field key in result is null;
if i remove backtick in @column("`key`") it works fine;
but when it excutes insert or update, it will throw a bad sql error;

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jun 21, 2024
@mp911de
Copy link
Member

mp911de commented Jun 21, 2024

R2dbcMappingContext doesn't quote identifiers by default. Can you retest when setting R2dbcMappingContext.setForceQuote(true)? I think you will have to register a custom R2dbcMappingContext bean.

@mp911de mp911de added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Aug 12, 2024
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Aug 19, 2024
@spring-projects-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2024
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Aug 26, 2024
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

No branches or pull requests

3 participants