Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 57186 invoked from network); 19 Jun 2004 04:24:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 19 Jun 2004 04:24:04 -0000 Received: (qmail 80264 invoked by uid 500); 19 Jun 2004 04:24:28 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 80239 invoked by uid 500); 19 Jun 2004 04:24:28 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 80217 invoked by uid 500); 19 Jun 2004 04:24:27 -0000 Received: (qmail 80201 invoked by uid 99); 19 Jun 2004 04:24:26 -0000 Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Fri, 18 Jun 2004 21:24:26 -0700 Received: (qmail 57158 invoked by uid 1610); 19 Jun 2004 04:24:00 -0000 Date: 19 Jun 2004 04:24:00 -0000 Message-ID: <20040619042400.57157.qmail@minotaur.apache.org> From: seade@apache.org To: db-torque-cvs@apache.org Subject: cvs commit: db-torque/src/test/org/apache/torque/util CriteriaTest.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N seade 2004/06/18 21:24:00 Modified: xdocs changes.xml src/java/org/apache/torque/util SqlExpression.java src/test/org/apache/torque/util CriteriaTest.java Log: Fix NOT_LIKE with no wildcard bug. Thanks to Clemens Fuchslocher for the patch which even included test cases!!! Revision Changes Path 1.124 +3 -0 db-torque/xdocs/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/db-torque/xdocs/changes.xml,v retrieving revision 1.123 retrieving revision 1.124 diff -u -r1.123 -r1.124 --- changes.xml 6 Apr 2004 12:50:06 -0000 1.123 +++ changes.xml 19 Jun 2004 04:24:00 -0000 1.124 @@ -8,6 +8,9 @@ + + Fix NOT_LIKE with no wildcard bug. + TRQS97: Fix bad syntax in generated model when using primary keys of short or byte. 1.27 +6 -1 db-torque/src/java/org/apache/torque/util/SqlExpression.java Index: SqlExpression.java =================================================================== RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/SqlExpression.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- SqlExpression.java 22 Feb 2004 06:16:35 -0000 1.26 +++ SqlExpression.java 19 Jun 2004 04:24:00 -0000 1.27 @@ -381,6 +381,11 @@ // use = (equals). Wildcards can be escaped by prepending // them with \ (backslash). String equalsOrLike = " = "; + if (comparison.equals(Criteria.NOT_LIKE)) + { + equalsOrLike = " " + Criteria.NOT_EQUAL + " "; + } + int position = 0; StringBuffer sb = new StringBuffer(); while (position < criteria.length()) 1.22 +54 -1 db-torque/src/test/org/apache/torque/util/CriteriaTest.java Index: CriteriaTest.java =================================================================== RCS file: /home/cvs/db-torque/src/test/org/apache/torque/util/CriteriaTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- CriteriaTest.java 22 Feb 2004 06:22:27 -0000 1.21 +++ CriteriaTest.java 19 Jun 2004 04:24:00 -0000 1.22 @@ -431,6 +431,59 @@ } /** + * This test case verifies if the Criteria.LIKE comparison type will + * get replaced through Criteria.EQUAL if there are no SQL wildcards + * in the given value. + */ + public void testLikeWithoutWildcards() + { + Criteria c = new Criteria(); + c.add("TABLE.COLUMN", (Object) "no wildcards", Criteria.LIKE); + + String expect = "SELECT FROM TABLE WHERE TABLE.COLUMN = 'no wildcards'"; + + String result = null; + try + { + result = BasePeer.createQueryString(c); + } + catch (TorqueException e) + { + e.printStackTrace(); + fail("TorqueException thrown in BasePeer.createQueryString()"); + } + + assertEquals(expect, result); + } + + /** + * This test case verifies if the Criteria.NOT_LIKE comparison type will + * get replaced through Criteria.NOT_EQUAL if there are no SQL wildcards + * in the given value. + */ + public void testNotLikeWithoutWildcards() + { + Criteria c = new Criteria(); + c.add("TABLE.COLUMN", (Object) "no wildcards", Criteria.NOT_LIKE); + + String firstExpect = "SELECT FROM TABLE WHERE TABLE.COLUMN != 'no wildcards'"; + String secondExpect = "SELECT FROM TABLE WHERE TABLE.COLUMN <> 'no wildcards'"; + + String result = null; + try + { + result = BasePeer.createQueryString(c); + } + catch (TorqueException e) + { + e.printStackTrace(); + fail("TorqueException thrown in BasePeer.createQueryString()"); + } + + assertTrue(result.equals(firstExpect) || result.equals(secondExpect)); + } + + /** * test for TRQS25 */ /* --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org