infobip / infobip-spring-data-querydsl

Infobip Spring Data Querydsl provides new functionality that enables the user to leverage the full power of Querydsl API on top of Spring Data repository infrastructure.
Apache License 2.0
281 stars 56 forks source link

[r2dbc] Apply `R2dbcCoverter` to `ConstantImpl` value in `where` clause #86

Closed davin111 closed 1 year ago

davin111 commented 1 year ago

I guess many people define some properties of classes mapped with tables as enum.

When selecting columns defined as enum, there is no problem because EntityRowMapper using R2dbcConverter executes simple conversions and user defined conversions (registered via r2dbcCustomConversions() of AbstractR2dbcConfiguration).

However, when using the columns with the where clause like where(user.status.eq(UserStatus.ONLINE), problems occur. The generated query not only apply Converter, but also doesn't enclose the enum value with quotation marks (ex> ... where ... user.status = ONLINE), thus it usually cause db exceptions like Unknown column 'ONLINE' in 'where clause'.

If this library supports those conversions, it will be very useful.

I don't think my implementation is not the best one, so please give me advice if you have better idea.

And... I want to do similar things for having clause, but sadly QueryMetadata of QueryDSL doesn't have clearHaving() method. So I handled only where clause, for now.

davin111 commented 1 year ago

Hi, @lpandzic. Could you check this PR and give some comments? I fixed tests and added supports for subqueries. Although predicates in having condition and join condition are not supported, I think this PR make building queries with enum fields easy.

lpandzic commented 1 year ago

Hi, can you add some tests that clearly show the intent?

lpandzic commented 1 year ago

I'm closing this one as stale. Feel free to reopen when you add tests.