Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Bug 573094: Fix LTRIM/RTRIM inversion of indices #1142

Merged
merged 1 commit into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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()) {
Expand All @@ -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();
Expand All @@ -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()) {
Expand Down Expand Up @@ -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();
Expand All @@ -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()) {
Expand All @@ -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();
Expand All @@ -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()) {
Expand Down