Ticket #923 (closed defect: invalid)
The result isn't correct if the table doesn't contain a primary key
| Reported by: | Garfield-fr | Owned by: | jwage |
|---|---|---|---|
| Priority: | major | Milestone: | 0.11.0 |
| Component: | Attributes | Version: | 0.10.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | ||
| Status: | Has Patch: |
Description
my schema:
Diagnostics:
tableName: diagnostics
columns:
id_type:
type: integer(4)
id:
type: integer(4)
diagnostic_id:
type: integer(4)
operator_id:
type: integer(4)
timestamp:
type: timestamp
extra_info:
type: string(200)
validation_id:
type: integer(4)
error:
type: integer(1)
relations:
Users:
local: operator_id
foreign: user_id
DQL:
$this->date_start = '2007-01-30 00:00:00';
$this->date_end = '2007-01-30 23:59:59';
$this->result = Doctrine_Query::create()
->select('d.*, u.*')
->from('Diagnostics d')
->where('d.timestamp >= ? AND d.timestamp <= ?', array($this->date_start, $this->date_end))
->leftJoin('d.Users u')
->addWhere('d.id_type = ?', array('101'))
->orderBy('d.timestamp')
->limit(20)
->offset(0)
->execute();
Doctrine SQL:
SELECT a.* FROM (SELECT d.id AS d__id, d.id_type AS d__id_type, d.diagnostic_id AS d__diagnostic_id, d.operator_id AS d__operator_id, d.timestamp AS d__timestamp, d.extra_info AS d__extra_info, d.validation_id AS d__validation_id, d.error AS d__error, u.user_id AS u__user_id, u.user_name AS u__user_name, u.first_name AS u__first_name, u.last_name AS u__last_name, u.last_login_time AS u__last_login_time, u.user_type AS u__user_type, u.active AS u__active FROM diagnostics d LEFT JOIN users u ON d.operator_id = u.user_id WHERE (d.timestamp >= ? AND d.timestamp <= ?) AND d.id_type = ? ORDER BY d.timestamp) a WHERE ROWNUM <= 20 - (2007-01-30 00:00:00, 2007-01-30 23:59:59, 101 )
--> Result: 13 records
Oracle SQL:
SELECT a.* FROM (SELECT d.id AS d__id, d.id_type AS d__id_type, d.diagnostic_id AS d__diagnostic_id, d.operator_id AS d__operator_id, d.timestamp AS d__timestamp, d.extra_info AS d__extra_info, d.validation_id AS d__validation_id, d.error AS d__error, u.user_id AS u__user_id, u.user_name AS u__user_name, u.first_name AS u__first_name, u.last_name AS u__last_name, u.last_login_time AS u__last_login_time, u.user_type AS u__user_type, u.active AS u__active FROM diagnostics d LEFT JOIN users u ON d.operator_id = u.user_id WHERE (d.timestamp >= to_date('2007-01-30 00:00:00', 'YYYY-MM-DD HH24:MI:SS') AND d.timestamp <= to_date('2007-01-30 23:59:59','YYYY-MM-DD HH24:MI:SS')) AND d.id_type = 101 ORDER BY d.timestamp) a WHERE ROWNUM <= 20
--> Result: 20 records
Change History
Note: See
TracTickets for help on using
tickets.