My logic is trying to do what you explained in the 2nd paragraph. As for the cases, where the parameters are excluded, parameters under a unary minus will be excluded automatically too because I have defined UnaryOperatorNode to extend ParameterNode. The existing code (where parameters are disallowed) checks for isParameterNode() and throws exception if isParameterNode() returns true. I have added the method isParameterNode() to UnaryOperatorNode which returns true if it is unary minus/unary plus and has a parameter for the operand. Because of this implementation scheme, I didn't have to go look at the existing parameter exclusion code to also check for unary minus/unary plus parameters.
I should have the code for review within a day or two, need to write comments and more tests.
On 10/2/05, Jeffrey Lichtman <firstname.lastname@example.org> wrote:
I've been thinking about where "- ?" should be allowed in queries.
Currently, parameters are allowed only in certain situations - the
documentation lists seventeen different places where parameters can
be used. These places were chosen because it's possible to figure out
the type of the parameter from the context. For example, a parameter
can be used as the first operand of BETWEEN as long as the one of the
second and third operands is not a parameter.
It seems to me that a parameter could be used with a unary minus
anywhere a "bare" parameter is allowed. Derby could use the same
rules to determine the type of the parameter as if the minus weren't
there. Obviously, there would have to be an error if the type isn't numeric.
I don't think we should allow unary minus on parameters in any other
cases. This seems obvious, but it means poring over the code and
looking for all the places where parameters are excluded, and making
it look for parameters under a unary minus.
- Jeff Lichtman
Check out Swazoo Koolak's Web Jukebox at