Development

#5192 ([PATCH] sfValidatorDoctrineChoice replaces "froms" and "joins" of custom queries)

You must first sign up to be able to contribute.

Ticket #5192 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

[PATCH] sfValidatorDoctrineChoice replaces "froms" and "joins" of custom queries

Reported by: eXtreme Assigned to: Jonathan.Wage
Priority: major Milestone: 1.2.1
Component: sfDoctrinePlugin Version: 1.2.0
Keywords: Cc:
Qualification: Unreviewed

Description

I'm using a custom query to customize records displayed in sfWidgetFormDoctrineChoice. It looks like that:

$query = Doctrine_Query::create();
$query->from('Type a')
      ->leftJoin('a.Parents p')
      ->addWhere('p.id = ?', 12345);

(it is a table with self-referenced Parents and Children)

The same query I want to use in validator sfValidatorDoctrineChoice. But it throws an exception because this validator replaces "from" and "leftJoin" with its own so my "where" fails (there is no "p" alias). It creates query like that: "FROM Type a WHERE p.id = ? AND a.id = ?" (replaced from, but where still exists)

This behaviour is different to widgets and sfValidatorDoctrineChoiceMany where "from" is attached only when no custom query is provided. See my patch and compare differences.

IMO there is also a small issue in sfValidatorDoctrineChoiceMany. Custom query behaviour is good here, but there is "whereIn" instead of "addWhereIn" so it overwrites all "wheres" from custom query.

Attachments

ticket.patch (1.7 kB) - added by eXtreme on 12/05/08 20:39:11.
ticket_2.patch (0.7 kB) - added by eXtreme on 12/10/08 17:56:58.
"addWhereIn" to "andWhereIn", also missing "dot"... sorry for that again :\

Change History

12/05/08 20:39:11 changed by eXtreme

  • attachment ticket.patch added.

12/05/08 22:29:53 changed by FabianLange

  • milestone set to 1.2.1.

12/09/08 00:49:43 changed by Jonathan.Wage

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

(In [13857]) [1.2] sfDoctrinePlugin: fisxes issue with choice validators (fixes #5192)

12/10/08 13:40:16 changed by pablodip

  • status changed from closed to reopened.
  • resolution deleted.

The function ->addWhereIn() don't exists, it is ->andWhereIn().

12/10/08 14:21:59 changed by eXtreme

Oh God that's my fault! Shame on me :( I fact, what I've just realised is that whereIn always works as "andWhereIn" so my "IMO" was pointles.. Sorry for that.

12/10/08 17:56:58 changed by eXtreme

  • attachment ticket_2.patch added.

"addWhereIn" to "andWhereIn", also missing "dot"... sorry for that again :\

12/10/08 23:15:12 changed by Jonathan.Wage

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

(In [13930]) [1.2] fixes small typo/mistake (closes #5192)

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.