Project

General

Profile

Bug #10920

String concatenation doesn't work in WHERE clause for permanent databases

Added by Stanislav Lomany 8 months ago. Updated 8 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

Related issues

Related to User Interface - Bug #10914: clicking browse hyperlinked cells does not load its content into a browser tab Review
Related to User Interface - Bug #10830: Search filter field on Guests screen of Hotel GUI does not work. WIP

History

#1 Updated by Stanislav Lomany 8 months ago

I used H2 permanent database. No records are found in FWD.

create guest. guest.first-name = "John". guest.last-name = "Smith". release guest.

for each guest where guest.first-name + " " + guest.last-name = "John Smith" no-lock:
    message "found".
end.

#2 Updated by Stanislav Lomany 8 months ago

  • Related to Bug #10914: clicking browse hyperlinked cells does not load its content into a browser tab added

#3 Updated by Constantin Asofiei 8 months ago

This is because of the H2's dialect automatic case-insensitive assumption in P2JH2Dialect; I've used a JDBC URL like this dbc:h2:../db/hotel;DB_CLOSE_DELAY=-1;MV_STORE=FALSE;RTRIM=TRUE;DEFAULT_IGNORE_CASE=TRUE;" and this patch so that the login works:

=== modified file 'src/com/goldencode/p2j/persist/ConnectionManager.java'
--- old/src/com/goldencode/p2j/persist/ConnectionManager.java   2025-11-05 15:01:44 +0000
+++ new/src/com/goldencode/p2j/persist/ConnectionManager.java   2025-11-24 08:14:54 +0000
@@ -2228,14 +2228,27 @@
       sb.append(MetadataSecurityOps.META_TABLE_USER);
       sb.append( " WHERE ");
       sb.append(pccUserid);
-      sb.append(" = upper(");
+      sb.append(" = ");
+      if (!dialect.isAutoCi())
+      {
+         sb.append("upper(");
+      }
       dialect.addRtrimmedExpression("?", sb);
-      sb.append(") AND ");
+      if (!dialect.isAutoCi())
+      {
+         sb.append(")");
+      }
+      sb.append(" AND ");
       sb.append(pccPassword);
       sb.append(" = ?");
       String query = sb.toString();
       try
       {
+         if (dialect.isAutoCi())
+         {
+            encPassword = encPassword.toUpperCase();
+         }
+         
          String[] paramList = new String[] { userid, encPassword };
          Object ufo = persistence.getSingleSQLResult(query, Persistence.META_CTX, paramList);

With this the report in #10914 works (i.e. it gets the file to be downloaded in embedded mode).

#4 Updated by Constantin Asofiei 8 months ago

  • Related to Bug #10830: Search filter field on Guests screen of Hotel GUI does not work. added

#5 Updated by Alexandru Lungu 8 months ago

I am OK with the changes in #10920-3. This piece of code is a backdoor into the persistence and wasn't handled properly when DEFAULT_IGNORE_CASE was introduced - we mostly considered FqlPreprocessor.
I looked for other usages of getSingleSQLResult, but this seemed to be the only one that had string fields/parameters used.

#6 Updated by Constantin Asofiei 8 months ago

Alex, as a side note: this query does not return records in H2: select * from meta_user where userid = rtrim('HOTEL');.

The JDBC URL has the DEFAULT_IGNORE_CASE=TRUE. It may be that rtrim returns a case-sensitive value. I can't tell if this is something of concern for our _temp and meta H2 in-memory databases.

#7 Updated by Alexandru Lungu 8 months ago

Is RTRIM=TRUE; set? H2 also knows to compare the values of strings with rtrim automatically.

#8 Updated by Alexandru Lungu 8 months ago

PS: I see dialect.addRtrimmedExpression("?", sb);. This can be wrapped with dialect.isAutoRtrim.

#9 Updated by Constantin Asofiei 8 months ago

Is not about a query from FWD, just a direct SELECT I noticed. Yes, RTRIM=TRUE is in the JDBC URL.

#10 Updated by Alexandru Lungu 8 months ago

Is not about a query from FWD, just a direct SELECT I noticed. Yes, RTRIM=TRUE is in the JDBC URL.

Right. The code is:

case RTRIM:
            result = ValueString.get(StringUtils.trim(v0.getString(), false, true, v1 == null ? " " : v1.getString()),
                    database);

This shows that the returned string is case sensitive. This is indeed a bug. I will fix it now.

Also available in: Atom PDF