/** Expect Underscores to not be escaped in LIKE queries **/ public void testQueryValueUnderscoreInMatch() throws Exception { QueryValue right = new QueryValue("%Hello_World"); QueryValue left = new QueryValue("Hello-World"); SimpleConstraint con = new SimpleConstraint(left, ConstraintOp.MATCHES, right); SqlGenerator.State state = new SqlGenerator.State(); StringBuffer buffer = state.getWhereBuffer(); SqlGenerator.simpleConstraintToString(state, buffer, con, null); assertEquals("'Hello-World' LIKE '%Hello_World'", buffer.toString()); }
/** Expect Underscores to not be escaped in LIKE queries **/ public void testQueryValueEscapedOpsInMatch() throws Exception { QueryValue right = new QueryValue("\\%Hello_Under\\_Score%"); QueryValue left = new QueryValue("%Hello-Under_Score!"); SimpleConstraint con = new SimpleConstraint(left, ConstraintOp.MATCHES, right); SqlGenerator.State state = new SqlGenerator.State(); StringBuffer buffer = state.getWhereBuffer(); SqlGenerator.simpleConstraintToString(state, buffer, con, null); String expected = "'%Hello-Under_Score!' LIKE E'\\\\%Hello_Under\\\\_Score%'"; assertEquals(expected, buffer.toString()); }
/** Expect underscores to be unescaped in other queries **/ public void testQueryValueUnderscoreInEquals() throws Exception { QueryValue right = new QueryValue("Hello_World"); QueryValue left = new QueryValue("HelloXWorld"); SimpleConstraint con = new SimpleConstraint(left, ConstraintOp.EQUALS, right); SqlGenerator.State state = new SqlGenerator.State(); StringBuffer buffer = state.getWhereBuffer(); SqlGenerator.simpleConstraintToString(state, buffer, con, null); assertEquals("'HelloXWorld' = 'Hello_World'", buffer.toString()); }
loseBrackets); } else if (c instanceof SimpleConstraint) { simpleConstraintToString(state, buffer, (SimpleConstraint) c, q); } else if (c instanceof SubqueryConstraint) { subqueryConstraintToString(state, buffer, (SubqueryConstraint) c, q, schema);
loseBrackets); } else if (c instanceof SimpleConstraint) { simpleConstraintToString(state, buffer, (SimpleConstraint) c, q); } else if (c instanceof SubqueryConstraint) { subqueryConstraintToString(state, buffer, (SubqueryConstraint) c, q, schema);