Skip to content

How to use 'ESCAPE' in DynamicSQL ? #916

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

Closed
lntlky7 opened this issue Mar 5, 2025 · 3 comments · Fixed by #917
Closed

How to use 'ESCAPE' in DynamicSQL ? #916

lntlky7 opened this issue Mar 5, 2025 · 3 comments · Fixed by #917

Comments

@lntlky7
Copy link

lntlky7 commented Mar 5, 2025

code

        var builder = SqlBuilder.select(selectList)
                .from(unit)
                .where();
        if (StringUtils.isNotEmpty(form.getCode())) {
            builder.and(code, SqlBuilder.isEqualTo(Short.valueOf(form.getCode())));
        }
        if (StringUtils.isNotEmpty(form.getSingle())) {
            builder.and(single, isLike(SQLUtil.likeDoubleSide(form.getSingle())));
        }
        if (StringUtils.isNotEmpty(form.getPlural())) {
            builder.and(plural, isLike(SQLUtil.likeDoubleSide(form.getPlural())));
        }
        List<Unit> modelList = mapper.selectPage(form.buildPage(), builder.build()
                .render(RenderingStrategies.MYBATIS3));

I want to use keyword ESCAPE for isLike. How to do? thanks.
like this: select * from unit where plural like ? escape ''

@jeffgbutler
Copy link
Member

This is quite difficult to do now, unfortunately. It will be easier in the next release. I will make an update shortly, and add an example.

@lntlky7
Copy link
Author

lntlky7 commented Mar 6, 2025

I had try some way to do this yestoday, like AbstractTwoValueCondition and AbstractNoValueCondition. but it doesn't work properly. if it could be updated, it would be a great help, thanks a lot.

@jeffgbutler
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants