Changeset 4777

Show
Ignore:
Timestamp:
08/19/08 00:14:01 (11 months ago)
Author:
guilhermeblanco
Message:

fixed #1329. Added checking for 2 words operator (NOT IN for example) in JoinCondition?.php

Location:
branches/1.0
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/lib/Doctrine/Query/JoinCondition.php

    r4768 r4777  
    3939        $e = $this->_tokenizer->sqlExplode($condition); 
    4040 
    41         if (count($e) > 2) { 
     41        if (($l = count($e)) > 2) { 
    4242            $expr = new Doctrine_Expression($e[0], $this->query->getConnection()); 
    4343            $e[0] = $expr->getSql(); 
    4444 
    4545            $operator  = $e[1]; 
     46 
     47            // FIX: "field NOT IN (XXX)" issue 
     48            // Related to ticket #1329 
     49            if ($l > 3) { 
     50                $operator .= ' ' . $e[2]; // Glue "NOT" and "IN" 
     51                $e[2] = $e[3]; // Move "(XXX)" to previous index 
     52 
     53                unset($e[3]); // Remove unused index 
     54            } 
    4655 
    4756            if (substr(trim($e[2]), 0, 1) != '(') { 
  • branches/1.0/tests/Query/JoinConditionTestCase.php

    r4715 r4777  
    3535    public function prepareData()  
    3636    { } 
    37      
     37 
    3838    public function prepareTables()  
    3939    { } 
    4040 
    41     public function testJoinConditionsAreSupportedForOneToManyLeftJoins() 
     41    /*public function testJoinConditionsAreSupportedForOneToManyLeftJoins() 
    4242    { 
    4343        $q = new Doctrine_Query(); 
     
    8282 
    8383        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.name = p.phonenumber WHERE (e.type = 0)"); 
     84    }*/ 
     85     
     86    public function testJoinWithConditionAndNotInClause() 
     87    { 
     88        // Related to ticket #1329 
     89        $q = new Doctrine_Query(); 
     90 
     91        $q->parseQuery("SELECT a.name, b.id FROM User a LEFT JOIN a.Phonenumber b WITH a.id NOT IN (1, 2, 3)"); 
     92 
     93        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id AND e.id NOT IN (1, 2, 3) WHERE (e.type = 0)"); 
    8494    } 
    8595} 
  • branches/1.0/tests/run.php

    r4774 r4777  
    119119$tickets->addTestCase(new Doctrine_Ticket_1304_TestCase()); 
    120120$tickets->addTestCase(new Doctrine_Ticket_1305_TestCase()); 
    121  
    122121$test->addTestCase($tickets); 
    123122