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

A custom operator with 2 arguments may fails #432

Closed
BuBuaBu opened this Issue Jun 4, 2013 · 6 comments

Comments

Projects
None yet
2 participants
@BuBuaBu

BuBuaBu commented Jun 4, 2013

When creating a custom operator with 2 arguments.
Adding the operator and pattern in a SQL Templates
If the first argument is a path and the second a constant,
then the serialization of the query fail with this exception :
java.lang.IllegalArgumentException: Expected 0 paths, but got 1
at com.mysema.query.sql.AbstractSQLQuery.setParameters(AbstractSQLQuery.java:531)
at com.mysema.query.sql.AbstractSQLQuery.getResults(AbstractSQLQuery.java:324)

A workaround is to add a third but not used argument

@BuBuaBu

This comment has been minimized.

Show comment
Hide comment
@BuBuaBu

BuBuaBu Jun 4, 2013

The bug is due to this part of code in SQLSerializer.class
@override
protected void visitOperation(Class type, Operator operator, List> args) {
if (args.size() == 2
&& args.get(0) instanceof Path && args.get(1) instanceof Constant
&& operator != Ops.STRING_CAST
&& operator != Ops.NUMCAST
&& operator != Ops.SUBSTR_1ARG
&& operator != Ops.CHAR_AT
&& operator != SQLTemplates.CAST) {
constantPaths.add((Path<?>)args.get(0));
}

BuBuaBu commented Jun 4, 2013

The bug is due to this part of code in SQLSerializer.class
@override
protected void visitOperation(Class type, Operator operator, List> args) {
if (args.size() == 2
&& args.get(0) instanceof Path && args.get(1) instanceof Constant
&& operator != Ops.STRING_CAST
&& operator != Ops.NUMCAST
&& operator != Ops.SUBSTR_1ARG
&& operator != Ops.CHAR_AT
&& operator != SQLTemplates.CAST) {
constantPaths.add((Path<?>)args.get(0));
}

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jun 8, 2013

Member

How does the pattern look like?

Member

timowest commented Jun 8, 2013

How does the pattern look like?

timowest added a commit that referenced this issue Jun 9, 2013

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jun 9, 2013

Member

Could you try again with the latest Querydsl snapshot from here https://oss.sonatype.org/content/repositories/snapshots/

Member

timowest commented Jun 9, 2013

Could you try again with the latest Querydsl snapshot from here https://oss.sonatype.org/content/repositories/snapshots/

@BuBuaBu

This comment has been minimized.

Show comment
Hide comment
@BuBuaBu

BuBuaBu Jun 9, 2013

The pattern looks like "cast({0} as number({1s}))"

The problem is fixed with latest snapshot.

Thanks!

BuBuaBu commented Jun 9, 2013

The pattern looks like "cast({0} as number({1s}))"

The problem is fixed with latest snapshot.

Thanks!

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jun 9, 2013

Member

Ok, then I guessed right and it was caused by the serialization of the argument directly into SQL

Member

timowest commented Jun 9, 2013

Ok, then I guessed right and it was caused by the serialization of the argument directly into SQL

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jun 26, 2013

Member

Released in 3.2.1

Member

timowest commented Jun 26, 2013

Released in 3.2.1

@timowest timowest closed this Jun 26, 2013

@timowest timowest added this to the 3.2.1 milestone Apr 14, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment