Skip to content

when i use isIn(emptyList) where condition, it would not render to sql #228

Closed
@clcy1243

Description

@clcy1243

code example

select(s -> s.where(id, isIn(new ArrayList<>()));

will render like this

select * from table

it should be like

select * from table where id in ()

and mysql where throw exception when execute this sql, it's what my want,
so i think there is a bug,
i found this code at org.mybatis.dynamic.sql.where.render.WhereConditionVisitor<T>

    public Optional<FragmentAndParameters> visit(AbstractListValueCondition<T> condition) {
        FragmentCollector fc = (FragmentCollector)condition.mapValues(this::toFragmentAndParameters).collect(FragmentCollector.collect());
        return fc.isEmpty() ? Optional.empty() : FragmentAndParameters.withFragment(condition.renderCondition(this.columnName(), fc.fragments())).withParameters(fc.parameters()).buildOptional();
    }

if list value condition accept an empty list, fc.isEmpty() will be true, this condition where be deleted

could anyone fix this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions