figonugroho opened a new issue, #8897:
URL: https://github.com/apache/hop/issues/8897

   ### Apache Hop version?
   
   SNAPSHOT-20261013
   
   ### Java version?
   
   Java 21.0.11
   
   ### Operating system
   
   Windows
   
   ### What happened?
   
   ### Summary
   In `Database` the constant `CONST_IS_NOT_NULL` is initialized to `IS NULL` 
instead of `IS NOT NULL`. Conditions using the `IS NOT NULL` operator are 
emitted as `... IS NOT NULL ?` (invalid SQL).
   
   ### Affected code
   `core/src/main/java/org/apache/hop/core/database/Database.java`
   
   ```java
   private static final String CONST_IS_NULL = "IS NULL";
   private static final String CONST_IS_NOT_NULL = "IS NULL";   // <-- wrong
   
   Used in the condition builder at lines ~2848, 2910, 2974:
   
   } else if (CONST_IS_NULL.equalsIgnoreCase(condition[i])
       || CONST_IS_NOT_NULL.equalsIgnoreCase(condition[i])) {
     sql.append(" ").append(condition[i]).append(" ");
   } else {
     sql.append(" ").append(condition[i]).append(" ? ");
   }
   ```
   
   ### Root cause
   `CONST_IS_NOT_NULL` holds `IS NULL`, a caller passing `IS NOT NULL` fails 
both equalsIgnoreCase checks and falls into the else branch, appending a ? 
placeholder. Resulting SQL is invalid: `... IS NOT NULL ?`
   
   ### Steps to reproduce
   1. Run a query/transform that uses an `IS NOT NULL` condition in a `WHERE` 
clause built through Database.getCondition/condition-string builder
   2. Observe the generated SQL contains `IS NOT NULL ?`
   
   ### Expected behavior
   The generated SQL should contain `IS NOT NULL` without a trailing parameter 
placeholder
   
   ### Actual behavior
   Generated SQL contains `IS NOT NULL ?`
   
   ### Fix
   ```java
   private static final String CONST_IS_NOT_NULL = "IS NOT NULL";
   ```
   Additional verification
   Confirmed the same constant pair exists and is correct in three other 
transforms, so this is isolated to Database:
   - plugins/transforms/insertupdate/.../InsertUpdate.java
   - plugins/transforms/synchronizeaftermerge/.../SynchronizeAfterMerge.java
   - plugins/transforms/update/.../Update.java
   - plugins/transforms/databaselookup/.../DatabaseLookup.java
   
   ### Issue Priority
   
   Priority: 3
   
   ### Issue Component
   
   Component: Hop Gui


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to