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

The insert operation must provide keyColumn, but no need before #53

Closed
snyang opened this issue May 1, 2022 · 6 comments
Closed

The insert operation must provide keyColumn, but no need before #53

snyang opened this issue May 1, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@snyang
Copy link

snyang commented May 1, 2022

The following content worked when use mybatis, but failed when use mybatis_r2dbc,

<insert id="insert" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">

To get the mybatis_r2dbc working, I have to provide values for keyColumn elements

<insert id="insert" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId" keyColumn="user_id">
@chenggangpro
Copy link
Owner

Could your provide a specific description , or demo project?

I checked my own used case and test suite about that,It works properly. Test case about insert return generated keys

FYI , The test running with mysql and mariadb-driver

@chenggangpro
Copy link
Owner

Sorry, I misunderstood, I will try to fix the problem later

@chenggangpro chenggangpro added enhancement New feature or request and removed enhancement New feature or request labels May 1, 2022
@chenggangpro
Copy link
Owner

chenggangpro commented May 1, 2022

Hi~,
I have checked the source code ,the problem you mentioned is actually caused by the inconsistency between JDBC driver and R2DBC driver definition.

  • 1 . the JDBC driver'sConnection provides a PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException; method, the second parameter of this method indicates whether auto returns generatedKeys
  • 2 . The R2DBC driver's Statement does not provide any method to return generatedKeys automatically, the Statement only has a Statement returnGeneratedValues(String... columns) method to return generatedKeys, the columns is not nullable ,so there column name must be specific.

Reference:

@snyang
Copy link
Author

snyang commented May 1, 2022

Thanks. better to throw an exception for the case.

@chenggangpro
Copy link
Owner

Thanks. better to throw an exception for the case.

Sounds appropriate.I'll work on this.Thanks for your suggestion

@chenggangpro chenggangpro added the enhancement New feature or request label May 1, 2022
@chenggangpro
Copy link
Owner

chenggangpro commented May 1, 2022

FYI: fixed in #56
I haven't released , this will be released in 1.0.10 later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants