phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\UnsupportedEagerOption
Eager loading does not support the 'limit' option: a…
Error message
Eager loading does not support the 'limit' option: a per-parent limit requires a window function, which PHQL cannot express
What it means
Thrown by PathTree::assertOptions() when an option map for an eager path contains 'limit'. PHQL cannot express ROW_NUMBER() OVER (PARTITION BY ...), so a per-parent limit cannot be implemented; applying a global limit to the batch query would silently return N rows total instead of N per parent, so the option is rejected outright.
Solutions
- Remove the 'limit' option from the eager path and enforce per-parent limits in application code after hydration
- Post-process the loaded relation and keep only the first N children per parent
- Use a native SQL query with a window function if a true per-parent limit is required
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Eager/PathTree.zep:87 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/8c3f2a4a8ae516dc.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Eager/PathTree.zep:87
throw new InvalidEagerPath(path);
}
let tree = self::insert(tree, path, segments, 0, options);
}
return tree;
}
/**
* A per-parent limit requires ROW_NUMBER() OVER (PARTITION BY ...), which
* PHQL has no syntax for. Applying `limit` to the batch query instead
* would return N children in total rather than N per parent, which is
* silently wrong.
*/
private static function assertOptions(array options) -> void
{
if unlikely isset options["limit"] {
throw new UnsupportedEagerOption("limit");
}
if unlikely isset options["offset"] {
throw new UnsupportedEagerOption("offset");
}
}
/**
* @param array $tree accumulated tree
* @param string $path the original path, for error messages
* @param array $segments exploded path
* @param int $index segment currently being inserted
* @param array $options attach to the last segment only
*/
private static function insert(
array tree,
string path,
array segments,View on GitHub (pinned to b7419de9cd)