Skip to content

Render in(emptyList) and notIn(emptyList) more reasonably #752

Closed
@pine-cones

Description

@pine-cones

I have read through the previously published issues: #228 and #509, and I strongly agree with jesusslim's idea.

I can understand that you never want to build invalid sql, but in my opinion, once we use isIn, whatever param we pass, you should never change our sql, we don't want fixing, if you think our sql is invalid just throw exception, not change it to another wrong sql.

In my understanding, the configuration nonRenderingWhereClauseAllowed only takes effect when there are no where conditions at all. When I use logical deletion, there will definitely be a where condition present. However, using in(emptyList) will modify all data, which is a very dangerous operation.

// will render to sql: update tableName set enabled = 0 where enabled = 1
update(dsl -> dsl.set(enabled).equalTo(false).where(enabled, isEqualTo(true)).and(id, isIn(Collections.emptyList())));

I'm thinking, if the condition is isIn(emptyList), can it be render to false? Similarly, isNotIn(emptyList) can be render to true. This ensures both the syntax and semantics of SQL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions