Skip to content

MySQL Mode: convertInsertNullToZero should be turned off by default? #1942

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

Closed
bood opened this issue May 23, 2019 · 2 comments · Fixed by #1944
Closed

MySQL Mode: convertInsertNullToZero should be turned off by default? #1942

bood opened this issue May 23, 2019 · 2 comments · Fixed by #1944

Comments

@bood
Copy link

bood commented May 23, 2019

On a real mysql, when insert a null value into a not null column, it will fail. However, h2 mysql mode does allow this happen by default. AFAIK h2 converts the null into zero by default.

I wonder why convertInsertNullToZero is turned on by default? I thought it should match the mysql behavior.

I saw a similar case here, but did not get really answered:
#250

Also a working solution here:
https://portal.permeance.com.au/web/terry.mueller/home1/-/blogs/solution-for-h2-not-failing-when-inserting-null-into-not-null-column-in-mysql-compatibility-mode

@katzyn
Copy link
Contributor

katzyn commented May 23, 2019

This compatibility code was written a long time ago when MySQL was very different from others. MySQL got a STRICT mode that disables different legacy tricks. It was enabled by default some time ago:
https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict

There is no normal way to toggle convertInsertNullToZero in H2, only the whole MySQL compatibility mode can be enabled. And the MySQL compatibility mode is the only one user of that compatibility code.

I'm not sure what to do with it. Because default behavior of MySQL was changed in 2015 we may want to remove this flag and all related code now for better compatibility with default behavior of modern versions. But somebody may still use this trick, of course.

@grandinj
What do you think?

@grandinj
Copy link
Contributor

yeah, lets tracks the behaviour of the current stable version of MySQL, we're not aiming to be perfect with these other-database modes

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

Successfully merging a pull request may close this issue.

3 participants