Issue Details (XML | Word | Printable)

Key: JDO-176
Type: Bug Bug
Status: Closed Closed
Resolution: Invalid
Priority: Major Major
Assignee: Erik Bengtson
Reporter: Michael Watzek
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JDO

JPOX fails when a query calls String.matches

Created: 07/Oct/05 12:55 AM   Updated: 19/Oct/05 07:35 PM
Return to search
Component/s: tck2
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Resolution Date: 19/Oct/05 07:35 PM


 Description  « Hide
JPOX fails when a query calls String.matches. This bug may be reproduced applying patch JDO-159. The SQL generation of the following query is incorrect:

SELECT FROM org.apache.jdo.tck.pc.company.Person WHERE firstname.matches('*First')

The LIKE clause of the generated SQL statement contains '*First'. This is a bug. It should contain '%First'.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig Russell added a comment - 15/Oct/05 02:16 PM
The parameter for "matches" is a regular expression. If '*First' is intended to be a wild card, it should be '.*First' instead. The wild card for regular expressions is dot star.

Michael Watzek added a comment - 17/Oct/05 05:46 PM
Component set to tck20.

Erik Bengtson added a comment - 17/Oct/05 06:00 PM
"*First" is invalid as regular expression.


Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
*First
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.matches(Unknown Source)
at java.lang.String.matches(Unknown Source)
at Test.main(Test.java:11)



public class Test
{

    /**
     * @param args
     */
    public static void main(String[] args)
    {
        System.out.println("kjdsd deoide First".matches("*First"));
        System.out.println("kjdsd deoide First".matches(".*First"));
        // TODO Auto-generated method stub

    }

}

Erik Bengtson added a comment - 17/Oct/05 06:01 PM
should the jdo implementation raise an exception or is it valid to query for '*First' (literally)?

Michael Watzek added a comment - 19/Oct/05 07:35 PM
This is not a bug because the regular expression passed to method "matches" is invalid.