pecee-pixie
pecee-pixie copied to clipboard
For having() method library adds a prefix
If the table has alias defined, the having() method adds the prefix before the key.
I think it shouldnt.
$qb
->newQuery()
->table(['p_table'=>'p'])
->select([
'p.id'=>'id',
$qb->raw('DATE(p.signTime) as docDate')
])
->having('docDate','=','2021-06-24')
->get();
I have the error:
Unknown column 'p.docDate' in 'having clause'
It's automatically prefixed to make it easier to add the alias after the fact without changing the entire query (when used in models etc) - when joining another table and so on.
It happening because the query builder doesn't recognize the alias docDate. Maybe the feature should be optional or have the alias automatically parsed from any raw statements.
Thanks for pointing out the issue!
I'll find a fix that'll make everyone happy.