[CONJ-216] insert with no value on not null column accepted Created: 2015-11-14 Updated: 2017-11-21 Resolved: 2017-11-21 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | Other |
| Affects Version/s: | 1.2.0, 1.3.0 |
| Fix Version/s: | 1.4.0 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Andreas Persson | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 14.04, MySQL 5.5.43-0ubuntu0.14.04.1, MariaDB Connector/J 1.3.0 |
||
| Description |
|
I'm not sure if this is a bug or if it's intentional, but MariaDB Connector/J behaves differently from mysql-connector-java when inserting lines without values on not null columns, when sql_mode doesn't include STRICT_TRANS_TABLES. With this table:
this statement:
succeeds with MariaDB Connector/J (1.3.0 and 1.2.0), but with mysql-connector-java (5.1.37), it throws a SQLException as a value for col1 is missing. If sql_mode is set to STRICT_TRANS_TABLES both drivers behave the same (throwing exception), so a work-around is maybe to add "?sessionVariables=sql_mode=STRICT_TRANS_TABLES" to the connection URL. (Storage engine is INNODB. Java-version on client is 8u60. Client runs on the same machine as the server.) |
| Comments |
| Comment by Diego Dupin [ 2017-11-21 ] |
|
1.4.0 solve this issue by adding STRICT_TRANS_TABLES to SQL_MODE at connection initialization to respect JDBC truncation specifications. |