Hi Ivan,
I don't know about the JIRA issue. As far as I know anybody who is logged in
can create issues.
I have no knowledge about granting or refusing access to anybody.
But I do have knowledge about the parenthesis issue.
We do not automatically create parenthesis as it imposes some restrictions or
at least might make complex expressions unreadable.
Hence, just as in real life, you have to specifically make your parentheses
where you need them.
In your case I guess
COL = T.A.plus(T.B).parenthesis().multiplyWith(2.0);
would be the solutions you are looking for.
Regards
Rainer
> from: Ivan Nemeth [mailto:[email protected]]
> to: [email protected]
> subject: Bug with DBColumnExpr.multiplyWith and divide
>
> Hi,
>
> (Rainer, couldn't create an issue in Jira, please can you check it? (missing
> permission maybe?))
>
> Empire generates wrong sql if you multiply a DBCalcExpr with some value,
> example:
>
> DBDatabase db = new DBDatabase() {
> };
> db.open(new DBDatabaseDriverHSql(), null); class Test extends DBTable {
>
> final DBTableColumn A;
> final DBTableColumn B;
> public Test(String name, DBDatabase db) { super(name, db); A =
> addColumn("A", DataType.INTEGER, 64, true); B = addColumn("B",
> DataType.INTEGER, 64, true); } }
>
> Test T = new Test("test", db);
> DBCommand cmd = db.createCommand();
> *DBColumnExpr COL = T.A.plus(T.B).multiplyWith(2.0);*
>
> cmd.select(COL);
>
> System.out.println(cmd.getSelect());
>
> The expected sql would be:
>
> *SELECT (t1.A + t1.B) * 2.0 FROM test t1*
>
> but Empire generates it with no parentheses
>
> *SELECT t1.A + t1.B * 2.0 FROM test t1*
>
> Solution would be to append parentheses in DBCalcExpr.addSql method
> something like this (it is required only for * and / operators):
>
> *buf.append("(");*
> expr.addSQL(buf, context);
> *buf.append(")"); *
> buf.append(op);
> // Special treatment for adding days to dates ...
>
> What do you think?
>
>
> Regards,
> Ivan