How to prevent/disable normalization of arithmetic expressions on query serialization

49 views
Skip to first unread message

Lars Knemeyer

unread,
Apr 8, 2015, 7:23:58 AM4/8/15
to quer...@googlegroups.com
Hi,

I use QueryDSL for literal query generation like this:


@Test
public void createEqualsQuery() {
   
final Configuration configuration = new Configuration(SQLServer2008Templates.builder().printSchema().build());
   configuration
.setUseLiterals(true);
   
final SimplePath<Object> table = Expressions.path(Object.class, "Tablename");
   
final StringPath column = Expressions.stringPath(table, "aColumn");
   
final SQLQuery sqlQuery = new SQLQuery(configuration).from(table).where(column.eq("A filter text"));
   
System.out.println(sqlQuery.getSQL(column).getSQL());
}


When I filter for an address like:

Carrera 52 con Ave. Bolívar #65-98 Llano Largo

the resulting query checks for:

 Carrera 52 con Ave. Bolívar #-33 Llano Largo


I understand this is caused by "normalization" when the query is serialized, although I can't really imagine any reasonable scenario for this behaviour to be useful (for Strings).
I also unterstand that "normalization" can be disabled by calling setNormalization(false) for the Serializer.

Is this behaviour intended? If yes, how can I disable it in my scenario since getSQL(Expression...) creates a local Serializer object that I cannot modify from outside? 


Best regards

Lars

Timo Westkämper

unread,
Apr 8, 2015, 7:25:57 AM4/8/15
to Querydsl on behalf of Lars Knemeyer
Do you use Querydsl 3.6.3?

--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lars Knemeyer

unread,
Apr 8, 2015, 7:59:40 AM4/8/15
to quer...@googlegroups.com
Sorry, I forgot the version. I was using 3.6.2, but I just checked I behaves the same with 3.6.3 for all operators.

column.eq("add 1+2 subtract 5-4 multiply 3*3 divide 10/2 end")

produces

 Tablename.aColumn = 'add 3 subtract 1 multiply 9 divide 5 end'


Am Mittwoch, 8. April 2015 13:25:57 UTC+2 schrieb timowest:
Do you use Querydsl 3.6.3?

Timo Westkämper

unread,
Apr 8, 2015, 8:52:34 AM4/8/15
to Querydsl on behalf of Lars Knemeyer
For now you can override createSerializer and call setNormalization(false)
Reply all
Reply to author
Forward
0 new messages