Ticket #788 (closed defect: fixed)

Opened 17 months ago

Last modified 17 months ago

Quick fix for count()/select and ENUM for 0.9

Reported by: Nail Owned by: zYne-
Priority: minor Milestone: 2.0.0 (OLD)
Component: Query/Hydration Version: 0.9.0
Severity: Keywords: enum
Cc: Has Test:
Status: Has Patch:

Description

My problem was that enum parameter structure was messed after count() call.

Example:

$q->from('Company c')->where('c.company_type=?', 'BANK'); // ENUM parameter
$q->count();
$q->where('c.id=?','c3_'); // Integer parameter
$result = $q->execute(); // wrong result here

The solution is to replace in Doctrine_Query::getQuery()

        // reset the state
        if ( ! $this->isSubquery()) {
            $this->_aliasMap = array();
            $this->pendingAggregates = array();
            $this->aggregateMap = array();
        }

with

        // reset the state
        if ( ! $this->isSubquery()) {
            $this->_aliasMap = array();
            $this->pendingAggregates = array();
            $this->aggregateMap = array();
            $this->_enumParams = array(); // the solution
        }

Attachments

count_enum.patch (0.6 KB) - added by Nail 17 months ago.

Change History

Changed 17 months ago by adrive

i don't know wheter I have the same problem, or I can fix my problem with your solution.

I try this basic query, where status is ENUM field and new is its first possible value (index 0):

    $count = Doctrine_Query::create()
    			->select('*')
    			->from('stSyslog')
    			->where('status = ?', 'new')
    			->count();

Mysql log this SQL query:

SELECT COUNT(DISTINCT l.id) AS num_results FROM logs l WHERE l.status = 'new'

Changed 17 months ago by guilhermeblanco

  • status changed from new to closed
  • resolution set to fixed

Changed 17 months ago by Nail

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 17 months ago by Nail

Changed 17 months ago by guilhermeblanco

  • status changed from reopened to closed
  • resolution set to fixed

(In [3789]) Small fix convertion of enum (fixes #788)

Note: See TracTickets for help on using tickets.