[
https://issues.apache.org/jira/browse/QPID-6717?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14728013#comment-14728013
]
Andrew Stitcher edited comment on QPID-6717 at 9/2/15 8:53 PM:
---------------------------------------------------------------
That's true for the non equality (<, <=, >, >=) operators because the spec says
they only work for numeric types and return false if any argument is non
numeric.
The equality operators (=, <>) do deal with all types.
{quote}
* Comparison operators: =, >, >=, <, <=, <> (not equal)
** Only like type values can be compared. One exception is that it is valid to
compare exact numeric values and approximate numeric values; the type
conversion required is defined by the rules of numeric promotion in the Java
programming language. If the comparison of non-like type values is attempted,
the value of the operation is false. If either of the type values evaluates to
NULL, the value of the expression is unknown.
** String and boolean comparison is restricted to = and <>. Two strings are
equal if and only if they contain the same sequence of characters.
{quote}
The BETWEEN operator is defined in terms of <= and >= so should use those
operators:
{quote}
* arithmetic-expr1 [NOT] BETWEEN arithmetic-expr2 AND arithmetic-expr3
(comparison operator)
** "age BETWEEN 15 AND 19" is equivalent to "age >= 15 AND age <= 19"
{quote}
was (Author: astitcher):
That's true for the non equality (<, <=, >, >=) operators because the spec says
they only work for numeric types and return false if any argument is non
numeric.
The equality operators (=, <>) do deal with all types.
{quote}
- Comparison operators: =, >, >=, <, <=, <> (not equal)
-- Only like type values can be compared. One exception is that it is valid to
compare exact numeric values and approximate numeric values; the type
conversion required is defined by the rules of numeric promotion in the Java
programming language. If the comparison of non-like type values is attempted,
the value of the operation is false. If either of the type values evaluates to
NULL, the value of the expression is unknown.
-- String and boolean comparison is restricted to = and <>. Two strings are
equal if and only if they contain the same sequence of characters.
{quote}
The BETWEEN operator is defined in terms of <= and >= so should use those
operators:
{quote}
- arithmetic-expr1 [NOT] BETWEEN arithmetic-expr2 AND arithmetic-expr3
(comparison operator)
-- "age BETWEEN 15 AND 19" is equivalent to "age >= 15 AND age <= 19"
{quote}
> selector can match incorrectly due to different type for values
> ---------------------------------------------------------------
>
> Key: QPID-6717
> URL: https://issues.apache.org/jira/browse/QPID-6717
> Project: Qpid
> Issue Type: Bug
> Components: C++ Broker
> Affects Versions: qpid-cpp-0.34
> Reporter: Gordon Sim
> Assignee: Andrew Stitcher
> Priority: Minor
> Fix For: qpid-cpp-next
>
>
> E.g. a selector "x BETWEEN 1 AND 10" would match for a value of x="foo",
> because of the way the logic is implemented for the between expression, or a
> selector "x NOT IN ('a', 'b', 'c')" would match where x=1, though it should
> not due to the type mismatch.
> From JMS spec: "Only like type values can be compared. One exception is that
> it is valid to compare exact numeric values and approximate numeric values"
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]