From 66805834cb304ca9b749ba7ad42053d9c5ff6568 Mon Sep 17 00:00:00 2001 From: Will Dazey Date: Mon, 17 May 2021 16:05:29 -0500 Subject: [PATCH] Bug 573094: Fix LTRIM/RTRIM inversion of indices Signed-off-by: Will Dazey --- .../expressions/ExpressionOperator.java | 8 -------- .../platform/database/OraclePlatform.java | 2 -- .../jpa/test/query/TestTrimFunction.java | 16 ++++++++-------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/expressions/ExpressionOperator.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/expressions/ExpressionOperator.java index c0873bb4823..6b31aa5954e 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/expressions/ExpressionOperator.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/expressions/ExpressionOperator.java @@ -1762,10 +1762,6 @@ public static ExpressionOperator leftTrim() { */ public static ExpressionOperator leftTrim2() { ExpressionOperator operator = simpleTwoArgumentFunction(LeftTrim2, "LTRIM"); - - // Bug 573094 - int[] indices = { 1, 0 }; - operator.setArgumentIndices(indices); return operator; } @@ -2405,10 +2401,6 @@ public static ExpressionOperator rightTrim() { public static ExpressionOperator rightTrim2() { // bug 2916893 rightTrim(substring) broken ExpressionOperator operator = simpleTwoArgumentFunction(RightTrim2, "RTRIM"); - - // Bug 573094 - int[] indices = { 1, 0 }; - operator.setArgumentIndices(indices); return operator; } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/platform/database/OraclePlatform.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/platform/database/OraclePlatform.java index 20c419e0f3c..350347675e7 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/platform/database/OraclePlatform.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/platform/database/OraclePlatform.java @@ -599,8 +599,6 @@ protected void initializePlatformOperators() { addOperator(operatorLocate2()); addOperator(regexpOperator()); addOperator(exceptOperator()); - addOperator(ExpressionOperator.simpleTwoArgumentFunction(ExpressionOperator.LeftTrim2, "LTRIM")); - addOperator(ExpressionOperator.simpleTwoArgumentFunction(ExpressionOperator.RightTrim2, "RTRIM")); } /** diff --git a/jpa/eclipselink.jpa.test.jse/src/it/java/org/eclipse/persistence/jpa/test/query/TestTrimFunction.java b/jpa/eclipselink.jpa.test.jse/src/it/java/org/eclipse/persistence/jpa/test/query/TestTrimFunction.java index 72a27038c69..3ac047d3785 100644 --- a/jpa/eclipselink.jpa.test.jse/src/it/java/org/eclipse/persistence/jpa/test/query/TestTrimFunction.java +++ b/jpa/eclipselink.jpa.test.jse/src/it/java/org/eclipse/persistence/jpa/test/query/TestTrimFunction.java @@ -116,7 +116,7 @@ public void testWhereLeftTrim() { if(platform.isMySQL() || platform.isDB2() || platform.isDerby() || platform.isSymfoware()) { Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = TRIM(LEADING 'A' FROM 'AAHELLO WORDAAAAA'))", _sql.remove(0)); } else { - Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = LTRIM('A', 'AAHELLO WORDAAAAA'))", _sql.remove(0)); + Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = LTRIM('AAHELLO WORDAAAAA', 'A'))", _sql.remove(0)); } CriteriaBuilder cb = em.getCriteriaBuilder(); @@ -135,7 +135,7 @@ public void testWhereLeftTrim() { if(platform.isMySQL() || platform.isDB2() || platform.isDerby() || platform.isSymfoware()) { Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = TRIM(LEADING 'A' FROM 'AAHELLO WORDAAAAA'))", _sql.remove(0)); } else { - Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = LTRIM('A', 'AAHELLO WORDAAAAA'))", _sql.remove(0)); + Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = LTRIM('AAHELLO WORDAAAAA', 'A'))", _sql.remove(0)); } } finally { if (em.isOpen()) { @@ -159,7 +159,7 @@ public void testWhereRightTrim() { if(platform.isMySQL() || platform.isDB2() || platform.isDerby() || platform.isSymfoware() || platform.isHSQL() || platform instanceof FirebirdPlatform) { Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = TRIM(TRAILING 'A' FROM 'AAHELLO WORDAAAAA'))", _sql.remove(0)); } else { - Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = RTRIM('A', 'AAHELLO WORDAAAAA'))", _sql.remove(0)); + Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = RTRIM('AAHELLO WORDAAAAA', 'A'))", _sql.remove(0)); } CriteriaBuilder cb = em.getCriteriaBuilder(); @@ -178,7 +178,7 @@ public void testWhereRightTrim() { if(platform.isMySQL() || platform.isDB2() || platform.isDerby() || platform.isSymfoware() || platform.isHSQL() || platform instanceof FirebirdPlatform) { Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = TRIM(TRAILING 'A' FROM 'AAHELLO WORDAAAAA'))", _sql.remove(0)); } else { - Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = RTRIM('A', 'AAHELLO WORDAAAAA'))", _sql.remove(0)); + Assert.assertEquals("SELECT STRVAL1 FROM TRIMENTITY WHERE (STRVAL1 = RTRIM('AAHELLO WORDAAAAA', 'A'))", _sql.remove(0)); } } finally { if (em.isOpen()) { @@ -249,7 +249,7 @@ public void testSelectLeftTrim() { if(platform.isMySQL() || platform.isDB2() || platform.isDerby() || platform.isSymfoware()) { Assert.assertEquals("SELECT TRIM(LEADING 'A' FROM 'AAHELLO WORDAAAAA') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); } else { - Assert.assertEquals("SELECT LTRIM('A', 'AAHELLO WORDAAAAA') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); + Assert.assertEquals("SELECT LTRIM('AAHELLO WORDAAAAA', 'A') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); } CriteriaBuilder cb = em.getCriteriaBuilder(); @@ -268,7 +268,7 @@ public void testSelectLeftTrim() { if(platform.isMySQL() || platform.isDB2() || platform.isDerby() || platform.isSymfoware()) { Assert.assertEquals("SELECT TRIM(LEADING 'A' FROM 'AAHELLO WORDAAAAA') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); } else { - Assert.assertEquals("SELECT LTRIM('A', 'AAHELLO WORDAAAAA') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); + Assert.assertEquals("SELECT LTRIM('AAHELLO WORDAAAAA', 'A') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); } } finally { if (em.isOpen()) { @@ -292,7 +292,7 @@ public void testSelectRightTrim() { if(platform.isMySQL() || platform.isDB2() || platform.isDerby() || platform.isSymfoware() || platform.isHSQL() || platform instanceof FirebirdPlatform) { Assert.assertEquals("SELECT TRIM(TRAILING 'A' FROM 'AAHELLO WORDAAAAA') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); } else { - Assert.assertEquals("SELECT RTRIM('A', 'AAHELLO WORDAAAAA') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); + Assert.assertEquals("SELECT RTRIM('AAHELLO WORDAAAAA', 'A') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); } CriteriaBuilder cb = em.getCriteriaBuilder(); @@ -311,7 +311,7 @@ public void testSelectRightTrim() { if(platform.isMySQL() || platform.isDB2() || platform.isDerby() || platform.isSymfoware() || platform.isHSQL() || platform instanceof FirebirdPlatform) { Assert.assertEquals("SELECT TRIM(TRAILING 'A' FROM 'AAHELLO WORDAAAAA') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); } else { - Assert.assertEquals("SELECT RTRIM('A', 'AAHELLO WORDAAAAA') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); + Assert.assertEquals("SELECT RTRIM('AAHELLO WORDAAAAA', 'A') FROM TRIMENTITY WHERE (STRVAL1 = 'HELLO')", _sql.remove(0)); } } finally { if (em.isOpen()) {