2009年2月26日星期四

Re: [fw-db] Opinions on ZF-5699 needed

(Sorry Jaka, forgot to do "reply all")

Throwing an exception is not something that will help me with my existing code base. But I must agree that this is the correct solution.

For the method findParentRow, it should return null because it's completly valid to have a row with a foreignkey NULL.

Imagine that in my use case of the projects and components, a components can have no project linked with fk_parent (the field is nullable) :

$tbl_components = new Components();
$comp = $tbl_components->createRow();
$comp->name = "Something";
$comp->save();


$project = $comp->findParentRow();

Actually, this throws an exception but it should return null, like older version of ZF.

I'm curious to see what propel or doctrine do with this use case.

2009/2/26 Jaka Jančar <jaka@kubje.org>
I agree with Matthew, it should throw an exception.

The rationale is simple:
Until a row object is saved, there _IS NO_ row and therefore there _CAN'T_ be any dependent rows (at least if referential integrity is maintained).

Indeed, there _AREN'T_ any rows, so one could argue that an empty rowset is the correct response, but that would be the same as if reading from a non-existent file returned 0 bytes instead of an error. Sure, there aren't any bytes, but there can't be any either.

Jaka


On 26. Feb 2009, at 16:54, Ralph Schindler wrote:

Link: http://framework.zend.com/issues/browse/ZF-5699

Title: Zend_Db_Table_Abstract::findDependentRowset throws an error when
called on unsaved Zend_Db_Table_Row (with PDO_MYSQL)

Hi all,

Take a moment to review the above (if you are interested), as I am
soliciting feedback as per what to do.

My question is, in such situations, should this return an empty rowset, or
should it throw an exception?

Please leave comments in the issue.

Thanks!
Ralph



--
Ralph Schindler
Software Engineer     | ralph.schindler@zend.com
Zend Framework        | http://framework.zend.com/






--
Sylvain Filteau
Programmeur/Analyste
sfilteau@ada-consult.com

ADA Consultants Inc
580 Grande-Allée Est, Suite #S20
Québec, QC
Canada, G1R 2K2
Tel.: 1 (418) 907-5904

没有评论: