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

tableAlias . included even for composed columns #78

Open
cbichis opened this issue Sep 4, 2015 · 2 comments
Open

tableAlias . included even for composed columns #78

cbichis opened this issue Sep 4, 2015 · 2 comments

Comments

@cbichis
Copy link

cbichis commented Sep 4, 2015

Hi,

The table alias "." is included into order even if the field is a composed one.

sample:

For
CONCAT(u.lastName, ' ', u.firstName) staff_name

Order looks like this:

ORDER BY .staff_name

So i created fix for ZfTable\Source\DoctrineQueryBuilder:

    protected function order()
    {
        $column = $this->getParamAdapter()->getColumn();
        $order = $this->getParamAdapter()->getOrder();

        if (!$column) {
            return;
        }

        $header = $this->getTable()->getHeader($column);
        $tableAlias = ($header) ? $header->getTableAlias() : 'q';

        if (false === strpos($tableAlias, '.')) {
            if(empty($tableAlias)){
                $tableAlias = $column;
            } else {
                $tableAlias = $tableAlias.'.'.$column;
            }
        }

        $this->query->orderBy($tableAlias, $order);
    }
@stijnhau
Copy link

Can you fork and create a PR so it's eadier to review the changes?

@cbichis
Copy link
Author

cbichis commented Nov 21, 2015

See now.

Can you fork and create a PR so it's eadier to review the changes?


Reply to this email directly or view it on GitHub
#78 (comment).

Cristian Bichis
IMAGIS
Strada Faiantei nr 13
550098 Sibiu, Romania
Phone: 004.0727.757533
Email: office@imagis.ro
Web: www.imagis.ro

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