empire-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Nemeth <ivan.nem...@gmail.com>
Subject Constraint on the same column
Date Fri, 11 Sep 2015 11:43:32 GMT
Hi,

another issue with constraints.

you can't add two constraint on the same column with
DBCommand.where(DBCommandExpr expr) method. The documentation says

"If another restriction already exists for the same column it will be
replaced."

So if I want to query persons who's name starts with "A" but is not "Adam",
I can do the following:

cmd.select(TABLE.getColumns());
cmd.where(TABLE.NAME.like("A%"));
cmd.where(TABLE.NAME.isNot("Adam"));

Due to the above mentioned restriction this won't work because the first
constraint will be dropped away, and I'll get ALL persons except Adam.

But if I use constraint list it's OK:

cmd.select(TABLE.getColumns());
List wheres = new ArrayList();
wheres.add(TABLE.NAME.like("A%"));
wheres.add(TABLE.NAME.isNot("Adam"));
cmd.addWhereConstraints(wheres);


Thanks,
Ivan

Mime
View raw message