This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I try debug my SQL for MySQL, but got error similar: "Error code 1364, SQL state HY000: Field '_lft' doesn't have a default value" Yes, '_lft' doesn't have a default value, but it is not problem - it is computed in triggers (automatic Nested Sets implementation). Console native mysql client does not complain about it and execute query perfectly.
Could you describe your use-case? DDL of the table (incl. trigger declaration) and SQL command for inserting values (or screen shot of Insert values dialog). It'll help to evaluate this problem. Thanks
Use case is very simple as INSERT INTO tablename set field1 = 'fieldvalue'; Statement was rejected from Netbeans IDE with error what listed not all fields which have not default values. But it is not always problem if such fields will populated in trigger (in any case). Console MySQL client already inserted such lines.
Bug description is not enough for me. Describe in detail by me previous comment (DDL table, SQL statemnt, trigger declaration).
Ok, full reproduce: DDL: DROP TABLE IF EXISTS `nb`; CREATE TABLE `nb` ( `id` int(11) NOT NULL, `field` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; delimiter ;; DROP TRIGGER IF EXISTS `test_nb_before_insert`;; CREATE TRIGGER `test_nb_before_insert` BEFORE INSERT ON `nb` FOR EACH ROW BEGIN set NEW.field := NEW.id + 7; END;; Then in NetBeans try execute statement: INSERT INTO nb (id) VALUES(1) you got error: Error code 1364, SQL state HY000: Field 'field' doesn't have a default value Line 1, column 1 Execution finished after 0 s, 1 error(s) occurred. Try check - no rows inserted in table. But it is incorrect, it statement fully legal, trying do the same in console: [pasha@bela Fascad]$ mysql -u test test < error.sql [pasha@bela Fascad]$ mysql -u test -e 'SELECT * from nb;' [pasha@bela Fascad]$ mysql -u test -e 'INSERT INTO nb (id) VALUES(1);' [pasha@bela Fascad]$ mysql -u test test -e 'SELECT * from nb;' +----+-------+ | id | field | +----+-------+ | 1 | 8 | +----+-------+ As you see, in console insert statement work correctly, and as expected 1 row in table!
Thanks. Now I can reproduce this problem, it worked as you wrote. I'll investigate if it's intentional behavior or a bug.
I made a simple Java application which executes that insert statement on same JDBC driver as NetBeans IDE does, it ends with the same SQLException: java.sql.SQLException: Field 'field' doesn't have a default value at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2562) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2512) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:781) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:624) Maybe there is a problem with the driver or some settings are missing.
I can setup mysql tool to prohibit insert new values as IDE, see: mysql> set @@sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; Query OK, 0 rows affected (0.00 sec) mysql> select @@sql_mode; +----------------------------------------------------------------+ | @@sql_mode | +----------------------------------------------------------------+ | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | +----------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> INSERT INTO nb (id) VALUES(3); ERROR 1364 (HY000): Field 'field' doesn't have a default value mysql> set @@sql_mode = ''; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO nb (id) VALUES(3); Query OK, 1 row affected, 1 warning (0.00 sec)
Already reported as http://bugs.mysql.com/bug.php?id=6295 Nothing to fix on IDE side.
Thank you for investigation. MySQL cli client have empty @@sql_mode by default and its work. In what (and for what) it setup netbeans? Can I change this mode for my IDE exemplar?
As a workaround, it works: set sql_mode = ''; INSERT INTO nb (id) VALUES(1);
How I make this mode by default in netbeans as temporary workaround?