diff --git a/include/class.orm.php b/include/class.orm.php index c71f0e1e60f4e8e5e0aac99a8bfca98d89fcba8b..e919e8f86952604f763649ea3946dbb9e339ef0c 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -2115,13 +2115,20 @@ class SqlCompiler { // Call pushJoin for each segment in the join path. A new JOIN // fragment will need to be emitted and/or cached $joins = array(); - $push = function($p, $model) use (&$joins, &$path) { + $null = false; + $push = function($p, $model) use (&$joins, &$path, &$null) { $J = $model::getMeta('joins'); if (!($info = $J[$p])) { throw new OrmException(sprintf( 'Model `%s` does not have a relation called `%s`', $model, $p)); } + // Propogate LEFT joins through other joins. That is, if a + // multi-join expression is used, the first LEFT join should + // result in further joins also being LEFT + if (isset($info['null'])) + $null = $null || $info['null']; + $info['null'] = $null; $crumb = $path; $path = ($path) ? "{$path}__{$p}" : $p; $joins[] = array($crumb, $path, $model, $info); diff --git a/include/class.staff.php b/include/class.staff.php index 8cc30b7db70608e84ad75228f0e2decbc6db325d..6709bac0d90e6f71e5b71822315389e24e0b6dc6 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -1143,10 +1143,6 @@ class StaffDeptAccess extends VerySimpleModel { 'joins' => array( 'dept' => array( 'constraint' => array('dept_id' => 'Dept.id'), - // FIXME: The ORM needs a way to support - // staff__dept_access__dept performing a LEFT join b/c - // staff__dept_access is LEFT - 'null' => true, ), 'staff' => array( 'constraint' => array('staff_id' => 'Staff.staff_id'),