Can't save relation in model if alias is camelCase
Model Foo has a bidirectional belongsTo/hasMany relationship with model BarBaz. In the relationship on Foo we aliased BarBaz as barBaz. If we try to save the model as follows:
$foo = new Foo();
$barBaz = new BarBaz();
$foo->barBaz = $barBaz;
$foo->create();
It screws up $foo (getMessages returns null [not even empty array, null] and the create call returns null). The creation also does not work. However, if the following is done:
$foo = new Foo();
$barBaz = new BarBaz();
$foo->barbaz = $barBaz;
$foo->create();
It will work properly. $foo->barBaz will be empty but $foo->barbaz will contain the nested relation and both will have been created.
Are you printing if any message is being created after save the record?
print_r($foo->getMessages());
As I mentioned initially, getMessages returns null (not even empty array) on $foo.
@andresgutierrez Is this case somehow related to #10800 and #10779?
Both of them are issues related to lowercase and camelCase alias.
@tobasar Thanks for pointing it out, taking a look
@andresgutierrez Any progress about this bug? Would love to help testing this bug again if you need.
@andresgutierrez I saw in manager.zep line 1100
/**
* Returns a relation by its alias
*/
public function getRelationByAlias(string! modelName, string! alias) -> <Relation> | boolean
{
var aliases, relation;
let aliases = this->_aliases;
if typeof aliases == "array" {
if fetch relation, aliases[strtolower(modelName . "$" . alias)] {
return relation;
}
}
return false;
}
What is the point lowering case the alias? Could it be the hiccup?
@nsossonko any update about this bug?
@tobasar I don't see this issue anymore in my application. Not sure why...