babyfish-ct / jimmer

A revolutionary ORM framework for both java and kotlin.
Apache License 2.0
882 stars 91 forks source link

[bug] Jimmer incorrectly composes nested 'and', 'or' predicates #700

Closed belovaf closed 1 month ago

belovaf commented 1 month ago
sql.createQuery(Book::class) {
            where(
                or(
                    and(
                        table.name eq "n1",
                        table.name eq "n2"),
                    and(
                        table.name eq "n3",
                        table.rating eq "n4")
                )
            )
            select(table)
        }.execute()

Generated where miss brackets:

where tb_1_.NAME = ? and tb_1_.NAME = ? or tb_1_.NAME = ? and tb_1_.NAME = ?
babyfish-ct commented 1 month ago

where p1 and p2 or p1 and p2 where (p1 and p2) or (p1 and p2) They are same