Reputation: 11
Some scripts I migrated are doing lots of
INSERT INTO `table` ( `id` , `fld2` , `fld3`) VALUES ( '', 'v2', 'v3')
id
is defined as: int(10) NOT NULL auto_increment
.
My database/mysql server (5.1.57) throws error:
1366 - Incorrect integer value: '' for column 'id' at row 1
''
was being accepted without syntax error and did auto-increment the integer field to the next number on the original server (5.1.52). Any idea what could be the difference in the mysql server setup? It couldn't be the version difference, both are 5.1.xx?
Upvotes: 0
Views: 3644
Reputation: 25249
Looks like the current server's default settings differ from the previous one. Have a look at MySQL's documentation regarding the strict mode settings.
Upvotes: 0
Reputation: 5320
Since id is auto_increment you should not mention it in your insert query :
INSERT INTO table (fld2 , fld3) VALUES ('v2', 'v3')
And besides you are inserting string in your id thus in case it was not auto_increment you would get the same error anyway.
Upvotes: 4