Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    •  
      CommentAuthoradityamooley
     

    With Posts hasMany Comments, the query created by Akelos fetches no posts if there are no comments for the given post.

    The query generated is

    SELECT __owner.id AS __owner_id, __owner.title AS __owner_title, __owner.body AS __owner_body, __owner.posted_on AS __owner_posted_on, _comments.id
    AS _comments_id, _comments.body AS _comments_body, _comments.post_id AS _comments_post_id, _comments.created_at AS _comments_created_at, 
    _comments.name AS _comments_name FROM posts AS __owner LEFT OUTER JOIN comments AS _comments ON __owner.id = _comments.post_id  WHERE 
    __owner.id = 2 AND _comments.post_id  = 2
    

    In the above query, the last condition AND _comments.post_id = 2 shouldn't be there since we are using LEFT JOIN to get the records. If this condition is written and there are no comments then the JOIN has no effect and query returns zero records. This in turn causes a FATAL error as follows:

    Fatal error: Call to a member function getId() on a non-object in /home/****/blog/app/views/post/compiled/show.tpl.php on line 4
    

    The correct query is

    SELECT __owner.id AS __owner_id, __owner.title AS __owner_title, __owner.body AS __owner_body, __owner.posted_on AS __owner_posted_on, _comments.id
    AS _comments_id, _comments.body AS _comments_body, _comments.post_id AS _comments_post_id, _comments.created_at AS _comments_created_at,
    _comments.name AS _comments_name FROM posts AS __owner LEFT OUTER JOIN comments AS _comments ON __owner.id = _comments.post_id  WHERE
    __owner.id = 2
    
    •  
      CommentAuthorbermi
     

    Can you open a ticket with a unit test detailing the bug, so we can see the problem clearly?

    •  
      CommentAuthoradityamooley
     

    OK. I have created a new ticket and attached a tarball with test, installers and a patch.

    •  
      CommentAuthorbermi
     

    Aditya, BIG THANKS for that contribution.

    Please see rev.315 for details on what had to be actually changed to get the unit tests passing on PHP4, PHP5 MySQL and SQLite. Read the commit details as it fixes other issues you reported.

    It's great to have such a contributions, but it will make it easier for the core team to integrate those changes if they where provided as a unified subversion diff patch like this

    •  
      CommentAuthoradityamooley
     

    Actually this was the first time I wrote a test and created a patch so was not exactly sure what was the best way to do it. But will keep this in mind when creating a patch next time (although I wish I won't have to do this again :P ).