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

User Defined Function and Comparison Operator #6278

Open
dautushenka opened this issue Feb 6, 2017 · 4 comments
Open

User Defined Function and Comparison Operator #6278

dautushenka opened this issue Feb 6, 2017 · 4 comments

Comments

@dautushenka
Copy link

dautushenka commented Feb 6, 2017

I work with PostgreSQL. I implemented custom function for working with array type
DQL: CONTAINS(field, '{1,2}')
which should converted into SQL: field @> '{1,2}'
When I was trying to apply with function I got error:

[Syntax Error] line 0, col -1: Error: Expected =, <, <=, <>, >, >=, !=, got end of string.

After digging into the code I found out that parser requires comparison operator also.
I use following workaround:
CONTAINS(field,?1) = TRUE

I think we need to implement ability to create custom operators.

@Ocramius
Copy link
Member

Ocramius commented Feb 6, 2017

What's missing is probably a boolean function - we support string/date/numeric atm, but not boolean.

@dautushenka
Copy link
Author

@Ocramius It also will fix the issue.

@zspine
Copy link

zspine commented Jul 7, 2017

Seems like most of the PostgreSQL functions requires it. I had the same issue with jsonb functions.

$qb = $this->createQueryBuilder('u');
$qb->andWhere('JSONB_EXISTS(u.roles, :role) = TRUE');
$qb->setParameter('role', User::ROLE_OWNER);
return $qb->getQuery()->getResult();

@dautushenka Thanks a lot for sharing the workaround!!! I have been trying to debug this for more than 4 hours....

@esbobkov
Copy link

esbobkov commented Nov 3, 2017

I have problem with Comparison Operator. I want to use POSIX Regular Expressions in Postgres. Operator is ~
But in not supported

@Majkl578 Majkl578 added this to the 3.0 milestone Dec 9, 2017
@Majkl578 Majkl578 added the DQL label Jan 10, 2018
@derrabus derrabus modified the milestones: 3.0.0, 4.0.0 May 11, 2022
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

6 participants