Mapper icon indicating copy to clipboard operation
Mapper copied to clipboard

Build incorrect SQL with Example when Sqls parameter is empty

Open sakaman opened this issue 2 years ago • 0 comments

Problem

Example build error SQL when Sqls parameter is empty, due to criterion may be empty sometimes.

Example

mapper.selectByExample(
                        Example.builder(Foo.class)
                                .where(Sqls.custom())
                                .orderByDesc(Foo.CODE)
                                .build()
                )

Generated the below incorrect SQL:

SELECT * FROM foo AND ORDER BY code Desc;

Possible Solution

Determine whether sqls.getCriteria().getCriterions is empty or not when using the where related method in tk.mybatis.mapper.entity.Example.Builder#where(tk.mybatis.mapper.util.Sqls)

sakaman avatar Apr 27 '23 08:04 sakaman