java-driver icon indicating copy to clipboard operation
java-driver copied to clipboard

CASSANDRA-19931: Support OR operator and sub-conditions in query builder

Open lukasz-antoniak opened this issue 1 year ago • 0 comments

Fix CASSANDRA-19931.

Example OR operator:

assertThat(
        selectFrom("foo")
            .all()
            .where(Relation.column("k").isEqualTo(literal(1)))
            .and()
            .where(Relation.column("l").isEqualTo(literal(2)))
            .or()
            .where(Relation.column("m").isEqualTo(literal(3)))
            .orderBy("c1", ASC)
            .orderBy("c2", DESC))
    .hasCql("SELECT * FROM foo WHERE k=1 AND l=2 OR m=3 ORDER BY c1 ASC,c2 DESC");

Example sub-condition:

assertThat(
        selectFrom("foo")
            .all()
            .where(Relation.column("k").isEqualTo(literal(1)))
            .and()
            .where(
                subCondition()
                    .where(Relation.column("l").isEqualTo(literal(2)))
                    .or()
                    .where(Relation.column("m").isEqualTo(literal(3))))
            .orderBy("c1", ASC)
            .orderBy("c2", DESC))
    .hasCql("SELECT * FROM foo WHERE k=1 AND (l=2 OR m=3) ORDER BY c1 ASC,c2 DESC");

lukasz-antoniak avatar Oct 03 '24 17:10 lukasz-antoniak