-
Notifications
You must be signed in to change notification settings - Fork 2
Description
When calling a model like this:
$actions = Actions::find('all', array( 'with' => array( 'Masters' ) ));
The model has a defined relationship likes this:
public $hasMany = array( 'Masters'=>array( 'key' => array('id' => 'action_id'), 'with' => array( 'MasterConditions' ) ) );
And the MasterConditions model referenced above is configured like this:
public $belongsTo = array('Masters');
This throws the following Fatal error:
[10-Nov-2012 15:32:42 UTC] PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Invalid query type
hasMany.' in \libraries\lithium\data\source\Database.php:445 Stack trace: #0 \libraries\lithium\data\source\Database.php(298): lithium\data\source\Database->renderCommand(Object(lithium\data\model\Query)) #1 \libraries\lithium\util\collection\Filters.php(202): lithium\data\source\Database->lithium\data\source{closure}(Object(lithium\data\source\database\adapter\MySql), Array, Object(lithium\util\collection\Filters)) #2 \app\libraries\li3_relations\extensions\data\Model.php(206): lithium\util\collection\Filters->next(Object(lithium\data\source\database\adapter\MySql), Array, Object(lithium\util\collection\Filters)) #3 \libraries\lithium\util\collection\Filters.php(183): li3_relations\extensions\data\Model::li3_relations\extensions\data{closure}(Object(lithium\data\source\database\adapter\MySql), Array, Object(lithium\uti in \libraries\lithium\data\source\Database.php on line 445
I have solved the problem by doing the following code right after: $relation = $alternateRelations[$relationKey]->data();
//set the type to read of this is not a mongodb connection if(is_a($self,'lithium\data\source\Database')) { $relation['type'] = 'read'; }
Hoping to see if you have a better solution.