Vinelab / NeoEloquent

The Neo4j OGM for Laravel
MIT License
635 stars 200 forks source link

count() fails on relation with constraint #139

Closed Anahkiasen closed 4 years ago

Anahkiasen commented 8 years ago

If I add a constraint to a relation (like an orderBy) and then try to call count() on it the generated query seems to fail:

public function steps()
{
    return $this->hasMany(Step::class, AbstractModel::LABELS['case_step'])->orderBy('order', 'ASC');
}
count($case->steps()->get()); // Works
$case->steps()->count(); // Fails
Vinelab\NeoEloquent\QueryException with message 'SyntaxException: steps not defined (line 1, column 130 (offset: 129))
"MATCH (case:`Case`), (case)-[rel_case_steps_steps:CASE_STEPS]->(steps:`Step`) WHERE id(case) = {idcase} RETURN count(*) ORDER BY steps.order ASC"
Mulkave commented 8 years ago

ORDER BY should be omitted with count.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.