Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For having() method library adds a prefix #146

Open
mrcnpdlk opened this issue Jun 24, 2021 · 1 comment
Open

For having() method library adds a prefix #146

mrcnpdlk opened this issue Jun 24, 2021 · 1 comment

Comments

@mrcnpdlk
Copy link
Contributor

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'

@skipperbent
Copy link
Owner

skipperbent commented Jun 25, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants