メモ(SQL::Makerでのjoin,JSON::PP::Boolean)
SQL::Makerでのjoin
いつも分からない,ってか無理☆だけど一応
欲しいSQL
SELECT comment.*, evaluation FROM comment LEFT JOIN comment_evaluation ON comment.uid = comment_evaluation.comment_id WHERE question_id = 1 ORDER BY comment.created DESC;
SQL::Maker使う
my $builder = SQL::Maker->new(driver => 'mysql'); $builder->select( undef, ['comment.*', 'evaluation'], { question_id => '1'}, { order_by => 'created DESC', joins => [ [comment => { type => 'LEFT', table => 'comment_evaluation', condition => 'comment.uid = comment_evaluation.comment_id' }], ], } );