}
public void testMatch() throws Exception
{
Pair attributes = parse("(firstName (addresses city))");
Query query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
parse("(and (match? (@ addresses city) \"Toronto\" 0.0) (= classCode \"CON\"))"),
parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);
query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
parse("(and (match? (@ addresses city) '(and \"Toronto\" \"abc\") 0.0) (= classCode \"CON\"))"),
null, -1, 0, false, Query.SEC_NONE, m_context);
assertEquals(0, query.read().size());
query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
parse("(and (match? (@ addresses city) \"Toronto'\" 0.0) (= classCode \"CON\"))"),
parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
query.read(); // test escape of quotes
query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
parse("(and (match? (@ addresses city) '(like? \"Toront\") 0.0) (= classCode \"CON\"))"),
parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);
query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
parse("(and (match? (@ addresses city) '(and \"Toronto\" (not \"Hill\")) 0.0) (= classCode \"CON\"))"),
parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);
query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
parse("(and (match? (@ addresses city) '(or \"Toronto\" \"abc\") 0.0) (= classCode \"CON\"))"),
parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);
query = Query.createRead(getMetadata().getMetaclass("Contact"), attributes,
parse("(and (match? (@ addresses city) '(* (1.0 \"Toronto\") (0.0 \"Toronto\")) 0.0) (= classCode \"CON\"))"),
parse("(((@ addresses city) . #t) ((@) . #t))"), -1, 0, false, Query.SEC_NONE, m_context);
AssertUtil.assertEquals(getURL("readCollectionWhere.xml"), query.read(), attributes);
}