#42267·appsmith

[Bug]: Oracle plugin - removeSemicolonFromQuery strips semicolons inside string literals, corrupting query data

Author: Chinmay0608Created Sep 20, 2026Updated Sep 20, 2026

Is there an existing issue for this?

  • I have searched the existing issues

Description

The Oracle plugin's removeSemicolonFromQuery method in OracleExecuteUtils.java uses a naive query.replaceAll(";", "") to strip semicolons before executing non-PL/SQL prepared statements (Oracle JDBC rejects trailing semicolons).

However, this blindly removes every semicolon in the SQL — including those inside string literals — which silently corrupts query data.

Steps To Reproduce

  1. Connect an Oracle datasource in Appsmith.
  2. Create a query using prepared statement mode with a static string literal containing a semicolon:
    sql
    INSERT INTO logs (message) VALUES ('Error; check connection')
  3. Execute the query.
  4. Observe the value stored in the database is 'Error check connection' — the semicolon was silently stripped.

Root Cause

OracleExecuteUtils.java lines 97–99:

java
public static String removeSemicolonFromQuery(String query) {
    return query.replaceAll(";", "");
}

Called from OraclePlugin.java lines 187–188 (prepared statement path only):

java
if (!isPLSQL(updatedQuery)) {
    updatedQuery = removeSemicolonFromQuery(updatedQuery);
}

Affected Queries (Examples)

sql
-- String literal with semicolon — value silently corrupted
INSERT INTO logs (message) VALUES ('Error; check connection')
-- Stored as: 'Error check connection'

-- WHERE clause with semicolon in string — wrong rows matched
SELECT * FROM t WHERE category = 'type; A'
-- Executes as: SELECT * FROM t WHERE category = 'type A'

-- Trailing semicolon (the intended case — should be removed)
SELECT * FROM employees;
-- Should become: SELECT * FROM employees  ✓

Expected Behavior

Only trailing semicolons that appear outside of string literals and comments should be stripped. Semicolons inside string literals (e.g., 'Error; check') must be preserved.

Public Sample App

No response

Environment

All environments (cloud, self-hosted)

Severity

High (Silent data corruption — no error is shown to the user)

Version

All versions using the Oracle plugin