db_delete('term_relation')->condition('tid1', $term->tid, 'OR')->condition('tid2', $term->tid)->execute() creates this kind of SQL:
DELETE FROM {term_relation} WHERE (tid1 OR :db_condition_placeholder_1331) AND (tid2 = :db_condition_placeholder_1332)
'tid1 OR :db_condition_placeholder_1331' is wrong and I'm not sure as to why this passes in MySQL but the 'OR' should be '='
This query causes many exceptions when running simpletests on a postgres database.
attached is patch which makes these tests pass.
2 in particular blogapi and taxonomy (obviously)
Comments
Comment #1
jhedstromThis patch looks good, and all the taxonomy and Blog API tests pass, with no exceptions, after applying the patch.
Pre-patch:
Taxonomy tests: 224 passes, 14 fails, and 60 exceptions
Blog API tests: Site breaks after running the tests, with this error:
Presumably because the cleanup can't happen due to exceptions?
with patch applied:
Taxonomy tests: 283 passes, 0 fails, and 0 exceptions
Blog API tests: 52 passes, 0 fails, and 0 exceptions
Comment #2
serenecloud commentedApplied patch to latest CVS HEAD, it looks good. (PostgreSQL 8.1)
Pre patch I got an uncaught exception, Post patch I get "335 passes, 0 fails, and 0 exceptions"
Comment #3
kaotien commentedFresh Drupal 7 install on MySQL
Pre-Patch: No fails or exceptions
--
Post-Patch: No fails or exceptions
Full results
Blog API - 52 passes, 0 fails, and 0 exceptions
Taxonomy - 283 passes, 0 fails, and 0 exceptions
Comment #4
serenecloud commentedWorks in PostgreSQL and MySQL,
I think we can put this as reviewed + tested by the community.
Comment #5
dries commentedI'm actually surprised this is working on MySQL. The function declaration of
condition()is:public function condition($field, $value = NULL, $operator = '=') {Clearly,
$operatoris never meant to be something like 'OR'.It looks like we need to have a test for this because it wasn't even tested on MySQL to begin with.
Comment #6
catchSo the 'OR' in there was my fault - bad dbtng conversion which slipped in with one of the taxonomy patches, mea culpa.
Looks like we're missing a test for deleting terms which have related terms - ought to be easy enough to add to the existing tests. Will roll a patch with that included in the next day or so if no-one beats me to it.
Comment #7
josh waihi commented@Dries what work needs to done on the patch to get it applied?
Comment #8
catch@mayer - we need to add to taxonomy.test so it explicitly tests deleting a
term which has related terms associatedterm relationship.Comment #9
catchHere it is with a test, apparently the delete just failed silently on MySQL without throwing an exception - so I added an explicit check that old relationships are removed when new ones are saved. Has one fail without the changes to taxonomy_term_save().
Comment #10
damien tournoud commentedThis is not PostgreSQL specific.
Comment #11
dries commentedCommitted to CVS HEAD. Thanks.