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

Whitespace in operators #216

Open
marcelloh opened this issue Dec 21, 2016 · 5 comments
Open

Whitespace in operators #216

marcelloh opened this issue Dec 21, 2016 · 5 comments
Assignees

Comments

@marcelloh
Copy link

I have this code:

$aFilter['appdeletedby_id'] = NULL;
$dataRecords = $this->select('distinct myField)
            ->where($aFilter)
            ->order([$field => 'ASC']);

and it works
but when I add another filter:

$aFilter['myField  != ' ] = '';

It doesn't work. I get a:
Unsupported operator '' in WHERE clause. If you want to use a custom operator, you can add one with \Spot\Query::addWhereOperator('', function (QueryBuilder $builder, $column, $value) { ... });

@willemwollebrants
Copy link
Contributor

There's a trailing space in the array key:

$aFilter['myField  != '  ];

If you remove the space, it should work:

$aFilter['myField  !=' ];

@marcelloh
Copy link
Author

Happy to see, that there is somehow a solution. I have to test this, but if it is like this, I would say it is an issue

@marcelloh
Copy link
Author

Just tested it. Nice workaround :-) and it will do for now, but I consider it a bug.

@marcelloh
Copy link
Author

The solution:
Query.php
->parseWhereToSQLFragments
was:

            // Column name with comparison operator
            $colData = explode(' ', $column);

becomes:

            // Column name with comparison operator
            $colData = explode(' ', trim($column));

@FlipEverything
Copy link
Contributor

I don't consider it a huge bug, but it doesn't hurt to create a PR with this modification.

@tuupola tuupola changed the title filter error (a puzzle) Whitespace in operators Mar 31, 2017
@tuupola tuupola self-assigned this Mar 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants