Skip to content

Conversation

@MorrisJobke
Copy link
Contributor

When following error message is shown, then it will get converted to the
correct Exception classs of NotNullConstraintViolationException:

PDOException: SQLSTATE[HY000]: General error: 1364 Field '...' doesn't have a
default value

The mentioned field has a Not Null constraint but no default value. I tested this with the latest mysql and mariadb docker container today (and with the mysql and mysqlnd PHP extension of the current Debian stable).

When following error message is shown, then it will get converted to the
correct Exception classs of NotNullConstraintViolationException:

  PDOException: SQLSTATE[HY000]: General error: 1364 Field '...' doesn't have a
  default value
@kimhemsoe
Copy link
Member

Tests?

@kimhemsoe
Copy link
Member

Sorry my mistake, did not see that you changed the test file. I will take a look at later and report back.

@MorrisJobke
Copy link
Contributor Author

Sorry my mistake, did not see that you changed the test file. I will take a look at later and report back.

Okay. I can also try to add some sort of integration test. Where should they then be added?

@deeky666
Copy link
Member

@MorrisJobke an integration test that reveals the issue would be great of course but I think the error only applies if the STRICT_TRANS_TABLES SQL mode is enabled in MySQL. So as it highly depends on a non default server setting, I doubt we can add a reliable integration test here.

Still the addition is valid of course, so I will accept it as is. Thanks @MorrisJobke !

@deeky666 deeky666 merged commit d6b1e11 into doctrine:master Jun 29, 2016
@deeky666 deeky666 added this to the 2.6 milestone Jun 29, 2016
@deeky666 deeky666 self-assigned this Jun 29, 2016
@MorrisJobke MorrisJobke deleted the no-default-value branch June 29, 2016 12:39
@MorrisJobke
Copy link
Contributor Author

I think the error only applies if the STRICT_TRANS_TABLES SQL mode is enabled in MySQL.

Thanks a lot for this information and for accepting this :)

@MorrisJobke
Copy link
Contributor Author

@deeky666 Should I prepare a backport for this to the 2.5 version?

@deeky666
Copy link
Member

deeky666 commented Jul 1, 2016

@MorrisJobke this is not a bug, this won't land in 2.5

@MorrisJobke
Copy link
Contributor Author

@MorrisJobke this is not a bug, this won't land in 2.5

Okay :) Thanks anyways

rullzer added a commit to nextcloud/3rdparty that referenced this pull request Oct 11, 2016
@Ocramius Ocramius changed the title Add error code mapping for "no default value" to MySQL driver Map custom exceptions for the "no default value" (1364) error in the MySQL drivers Jul 22, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants