tags:

views:

21

answers:

1

First of all, I know this SHOULDN'T work. We're using a very old DAL/ORM (Pear/DB/GenericDao based) layer that incorrectly surmises that id is not an autoincrement/integer field.

This statement DOES work in 5.0 Linux, DOES NOT work in 5.1 Windows. Is there a setting that could be different in my ini (ignore_type_errors="yes":))? I really don't want to add rewriting/upgrading this DAL/ORM (which predates me at the company) to the server upgrade tasks.

Statement

INSERT INTO Party SET partyTypeID = 'PERSON',id = '',comment = '';

Error

Error Code: 1366
Incorrect integer value: '' for column 'id' at row 1)

DDL for Table

CREATE TABLE `Party` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `partyTypeID` varchar(32) NOT NULL DEFAULT '',
  `comment` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `partyTypeID` (`partyTypeID`)
) ENGINE=MyISAM AUTO_INCREMENT=1017793 DEFAULT CHARSET=latin1;
+4  A: 

You are probably using a more strict SQL_MODE in 5.1 than you were using in 5.0, thus what used to be a warning is now an error.

What SQL_MODE are you using?

SELECT @@GLOBAL.sql_mode;

Here's an example to show how to get rid of the error:

mysql> set sql_mode = 'STRICT_TRANS_TABLES';
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO Party SET partyTypeID = 'PERSON',id = '',comment = '';
ERROR 1366 (HY000): Incorrect integer value: '' for column 'id' at row 1
mysql> set sql_mode = '';
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO Party SET partyTypeID = 'PERSON',id = '',comment = '';
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+------------------------------------------------------+
| Level   | Code | Message                                              |
+---------+------+------------------------------------------------------+
| Warning | 1366 | Incorrect integer value: '' for column 'id' at row 1 |
+---------+------+------------------------------------------------------+
1 row in set (0.00 sec)
Ike Walker
That was it! Thanks so much! I am a little surprised that you can actually turn off type checking.
evilknot