Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
database system
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
31 Aug 2008 at 21:04 UTC
Updated:
27 Nov 2008 at 21:32 UTC
Jump to comment: Most recent file
Comments
Comment #1
chx commentedNow, this fixes a bug in mysql schema.inc (sorry for the many whitespace cleanups, the fix is === null instead of ==) and with the strict mode patch i submitted it actually passes with mysql as well. Strict mode at http://drupal.org/node/303054
Comment #2
fgmAs you said, it doesn't pass without the MySQL strict fix. However, IMHO the problem is not with the test but with the DB API.
What happens is that you start with:
but then when the table is created in MySQL, the NULL default on field "id" is not passed during creation. And you get a field "id" like "`test` int(11) NOT NULL", without a default, although the test requests a NULL default. This comes from
DatabaseSchema_mysql->createFieldSql(), which tests for:which causes it to ignore NULL defaults. The problem could be removed by using something stricter like:
Now, if you use this, the table creation is simply rejected, and the test cannot proceed to the subsequent errors. OTOH, I suppose it may break other code elsewhere which uses such DDL, and which should probably be fixed.
The test itself, though, has another potential problem: if db_create_table fails, none of the subsequent tests can proceed, so it might make more sense to drop out of the test if the initial table creation fails. When testing interactively, this is not an issue, but since each test is costly, for automated testing it could make more sense to fail early than to let a full series of failure happen. But this is more a policy than a technical issue, and I'm not (yet ?) aware of the policy choices in that regard.
Comment #3
chx commentedOh so my little test already caught two MySQL schema bugs? That's good! Enrolled the default NULL fix and changed the test table definiton not to have a default NULL on a NOT NULL column (what I was thinking??)
Comment #4
fgmOut of sheer curiosity, why did you replace
is_null($spec['default'])by!isset($spec['default'])?It seems to give the same result in this specific case, although it is maybe a bit harder to read because it is less specific; maybe it's a core style guide issue ?
This being said, i think it would also make sense to ask for that NULL default on non-NULL column, and make sure an error is indeed returned and the table is not created. It could make another case for the test.
Comment #5
Anonymous (not verified) commentedThe last submitted patch failed testing.
Comment #6
damien tournoud commentedCleaned-up the schema API test (and only it), the fix for drivers should go in a different issue, IMO.
Comment #7
Anonymous (not verified) commentedThe last submitted patch failed testing.
Comment #8
damien tournoud commentedComment #9
Anonymous (not verified) commentedThe last submitted patch failed testing.
Comment #10
damien tournoud commentedFixed missing
{}in the queries.Comment #11
damien tournoud commentedThe fix for the MySQL implementation is now in a separate issue: #333499: Fix handling of NULL default values in MySQL schema API
Comment #12
damien tournoud commentedImproved version: we now check that the previously inserted rows are kept when changing the definition of a field (this is useful because the SQLite implementation migrate the data to a new table because there is limited ALTER TABLE support on that engine).
Comment #13
dries commentedCommitted to CVS HEAD. Other test to follow soon.
Comment #14
damien tournoud commented@Dries: apparently you committed #10, not #12.
Comment #15
damien tournoud commentedHere is a patch against HEAD.
Comment #16
damien tournoud commentedLatest patch had a strange $Id$.
Comment #17
dries commentedThanks for the prompt help. Committed to CVS HEAD. Thanks.