Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 11233 invoked from network); 12 Oct 2006 15:02:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Oct 2006 15:02:55 -0000 Received: (qmail 68856 invoked by uid 500); 12 Oct 2006 15:02:54 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 68842 invoked by uid 500); 12 Oct 2006 15:02:54 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 53685 invoked by uid 99); 12 Oct 2006 09:12:04 -0000 X-ASF-Spam-Status: No, hits=2.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of partha.t@gmail.com designates 64.233.182.191 as permitted sender) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=Nzln63NBmxE2qH7T1oPaYdr8u6YQ7i4ZEmIHMwNQ5ZEYFTcVVcgA7jxxo0Gy5MkvSwN7v+h/zRUGMCq3LOW1gvnV6PpuBcuVLe/TDnY26zoHK4c81oIm82pzCXM/64tts5vBTRFXRIavnjl5it0z5QVRP2jlzKYlr0DYmKT8v6Y= Message-ID: <6f13c2a30610120211m17257299x4a300683de517d32@mail.gmail.com> Date: Thu, 12 Oct 2006 14:41:40 +0530 From: "Parthasarathy T" To: torque-user@db.apache.org, torque-dev@db.apache.org Subject: Doubt in the SQLExpression formed by buildLike method MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_25602_23174899.1160644300312" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_25602_23174899.1160644300312 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi all, I have a small doubt in the SQLExpression formed by the buildLike method. I= f i understand the comments correctly if criteria =3D 50\%, it will be change= d to columnName =3D 50% /** * Takes a columnName and criteria and builds an SQL phrase based * on whether wildcards are present and the state of the * ignoreCase flag. Multicharacter wildcards % and * may be used * as well as single character wildcards, _ and ?. These * characters can be escaped with \. * * e.g. criteria =3D "fre%" -> columnName LIKE 'fre%' * -> UPPER(columnName) LIKE UPPER('fre%') * criteria =3D "50\%" -> columnName =3D '50%' * * @param columnName A column name. * @param criteria The value to compare the column against. * @param comparison Whether to do a LIKE or a NOT LIKE * @param ignoreCase If true and columns represent Strings, the * appropriate function defined for the database will be used to * ignore differences in case. * @param db Represents the database in use, for vendor specific functions. * @param whereClause A StringBuffer to which the sql expression * will be appended. */ static void buildLike(String columnName, String criteria, SqlEnum comparison, boolean ignoreCase, DB db, StringBuffer whereClause) { Check the loop logic below - first sb is filled with *5 *and then *0 *and then it encounters \ - the code now enters the *case BACKSLASH: *where we check the next character while is % so it enters the % case and so the position gets incremented by 1 automatically - the checkWildcard at this time will be still \ and not % and so when the checkWildcard gets appended to sb we will be appending \ and we would have skipped % altogether (becaus= e of position++) At the end of the loop we will be having sb=3D 50\ and not 50%. Is this a bug?? Most of time we may not have faced the problem because we would have come i= n criteria =3D 50\\% (because of *quoteAndEscapeText() *method appending an extra slash for most dbs). StringBuffer sb =3D *new* StringBuffer(); * StringBuffer sb =3D new StringBuffer(); while (position < criteria.length()) { char checkWildcard =3D criteria.charAt(position);* * switch (checkWildcard) { case BACKSLASH: // Determine whether to skip over next character. switch (criteria.charAt(position + 1)) { case '%': case '_': case '*': case '?': case BACKSLASH: position++; break; } break; case '%': case '_': escapeCharFound =3D true; equalsOrLike =3D comparison.toString(); break; case '*': equalsOrLike =3D comparison.toString(); checkWildcard =3D '%'; break; case '?': equalsOrLike =3D comparison.toString(); checkWildcard =3D '_'; break; }* * sb.append(checkWildcard); position++; } whereClause.append(equalsOrLike);* sb.append(checkWildcard); position++; } Thanks, *T.Parthasarathy *=95 SunGard =95 Offshore Services =95 Divyasree Chamber= s Langford Road =95 Bangalore 560025 India Tel +91-80-2222-0501 =95 Mobile +91-99450-00394 =95 Fax +91-80-2222-0511 = =95 * www.sungard.com* *Please note my email address =96 Parthasarathy.Thandavarayan@sos.sungard.com. Please update your contact list and use this address for all future communication.* CONFIDENTIALITY: This email (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited. If you received this email in error, pleas= e notify the sender and delete this email from your system. Thank you. ------=_Part_25602_23174899.1160644300312--