Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Removing `Entity::_relationships` and refactoring `Entity::__isset` & `Entity::__unset` : WARNING BC BREAK. #572

wants to merge 1 commit into


None yet
3 participants

jails commented Jul 12, 2012

Separating Entity::_relationships & Entity::_updated has imo not a good thing since they are both datas and currently such separation only work on the loading step. Indeed if I use the following syntax :

$entity->mydata = $somedata // the datas goes into _updated even if it's a relation

So I think it's preferable to remove this feature for the moment and rethink of it when it'll be really necessary.

Secondarily close #571


nateabele commented Jul 14, 2012

Relationships are fully implemented for Record/RecordSet. They already work correctly for relational databases, and will soon work correctly for non-relational as well. So this patch completely breaks existing relationship support.


jails commented Jul 14, 2012

Yeah relationships are fully implemented and imo it's not reliyed on the way datas are stored. In this PR $_relationship is removed and all test pass anyway. Moreover $_relationship is not representative of $_relationship where updates are done on $_update. Actually it's just merged to $_updated and don't bring any extra features, only extra checks. Imo relationships more rely on the way to extract and detect them easily when needed (this is the aim of #575). Here $_relationship are extracted on finds but not used.

@hans-d hans-d commented on the diff Jul 21, 2012

+ return isset($this->_updated[$name]);
+ }
+ /**
+ * PHP magic method used when unset() is called on an `Entity` instance.
+ * {{{
+ * $doc = Post::find($id);
+ * unset($doc->fieldName);
+ * $doc->save();
+ * }}}
+ *
+ * @param string $name The name of the field to unset.
+ * @return void
+ */
+ public function __unset($name) {
+ unset($this->_updated[$name]);

hans-d Jul 21, 2012


should we do a unset(), or reset it to the value of $this->_data[$name] when available?

For NoSQL unset makes sense, for SQL it does not. For other datasources it may vary. (originally the unset is only present in Document)

@nateabele nateabele closed this Dec 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment