Vinelab / NeoEloquent

The Neo4j OGM for Laravel
MIT License
633 stars 197 forks source link

chunk confusing child's Label with parent label #237

Closed jasekiw closed 3 years ago

jasekiw commented 7 years ago

When chunking through results and then grabbing a list of nodes from each node it confuses which label it is using.

TemplateForm::orderBy('created_at', 'ASC')->chunk(2, function(Collection $templates)  {
    $templates->each(function($template)  {
          $pages = $template->pages;
     });
});

Throws error

  [Vinelab\NeoEloquent\QueryException]                                         
  SyntaxException: Variable `pages` not defined (line 1, column 43 (offset: 4  
  2))                                                                          
  "MATCH (templateForm:`TemplateForm`) WHERE pages.deleted_at is null RETURN   
  * ORDER BY pages.created_at ASC SKIP 2 LIMIT 2" 

The query works fine until I access the children.

This is very strange and seems like a reference issue. if I take out the chunk and replace it with a standard each everything works as expected. I cannot however pull all of these at once.

Mulkave commented 6 years ago

Not aware of chunk's functionality, can you please elaborate on its usage/need?

jasekiw commented 6 years ago

https://laravel.com/docs/5.4/queries Scroll down until you see "Chunking Results".

Mulkave commented 6 years ago

Oh that! No tests exist for that atm so can't tell about this feature's compatibility. If you have the time for a PR I'd love to look at and merge. Thanks for reporting.

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.