6.0.0-alpha10
▾
Tasks
New Task
Search
Photos
Wiki
▾
Tickets
New Ticket
Search
dev.horde.org
Toggle Alerts Log
Help
5/16/25
H
istory
A
ttachments
C
omment
W
atch
Download
Comment on [#10880] Rdo: Make *- to-one-relations aware of "no relation" state
*
Your Email Address
*
Spam protection
Enter the letters below:
.__ . ..__ . ..__ [__)| |[ __|__|[__) [__)|/\|[_./| || \
Comment
> I feel the current behaviour of Horde_Rdo resolving to-one-relations > for the corner case of NULL or "empty string" in the relation key > field is misleading. > > Example: > > Two data entities exist, a network host table and a certificate table. > A host may or may not have a certificate. > > Since certificates are managed for other objects too it is not > feasible to reverse the relation and say the certificate must > reference the host. > > CREATE TABLE `appname_hosts` ( > `host_id` int(10) NOT NULL auto_increment, > `certificate_id` int(10) default NULL, > #[... more fields that don't matter here] > PRIMARY KEY (`host_id`) > ) ENGINE=MyISAM AUTO_INCREMENT=125 DEFAULT CHARSET=latin1 > > CREATE TABLE `appname_certificates` ( > `certificate_id` int(10) unsigned NOT NULL auto_increment, > `certificate_crt` text, > `certificate_key` text, > `ca_id` int(10) default NULL, > `certificate_cn` varchar(100) default NULL, > `certificate_csr` text, > `certificate_pkcs12` text, > PRIMARY KEY (`certificate_id`) > ) ENGINE=MyISAM AUTO_INCREMENT=151 DEFAULT CHARSET=latin; > > Now we have a Appname_HostMapper Class with relation > > protected $_lazyRelationships = array( > 'certificate' => array('type' => Horde_Rdo::ONE_TO_ONE, > 'foreignKey' => 'certificate_id', > 'mapper' => 'Appname_CertificateMapper') > ); > > Now when I have a Host table entry with value of '' or NULL, I do get > an instance of Appname_Certificate as a response, usually the first > entry in the table (with default order). > > Rdo currently doesn't understand the concept of a missing relation. > I'd suggest to either return no object or an exception. > Consistence with to-many-relations is hard. > These relations always return a list object, possibly an empty one. > As to-one-relations are often used in chains (at least in my code) > I'd prefer a clean exception over an empty result but the current > situation is worst for me. > > My current workaround is to check length($this->certificate_id) > before accessing $this->certificate but it's obviously not a clean > solution. > > I've classified this as an enhancement rather than a bug because it > breaks current behaviour and Rdo possibly wasn't designed with this > case in mind.
Attachment
Watch this ticket
N
ew Ticket
M
y Tickets
S
earch
Q
uery Builder
R
eports
Saved Queries
Open Bugs
Bugs waiting for Feedback
Open Bugs in Releases
Open Enhancements
Enhancements waiting for Feedback
Bugs with Patches
Enhancements with Patches
Release Showstoppers
Stalled Tickets
New Tickets
Horde 5 Showstoppers