Skip to content

Commit

Permalink
fix tests failing on OracleDB
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Feb 27, 2024
1 parent c8e02a4 commit 9e60c41
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public Object invoke(XRServiceAdapter xrService, Invocation invocation) {
if (value != null) {
// a recent change in core results in an empty vector being returned in cases
// where before we'd expect an int value (typically 1) - need to handle this
if (result != null && (result.getType() == INT_QNAME || result.getType().equals(SXF_QNAME))) {
if (result != null && (INT_QNAME.equals(result.getType()) || SXF_QNAME.equals(result.getType()))) {
if (value instanceof ArrayList && ((ArrayList<?>) value).isEmpty()) {
((ArrayList<Integer>) value).add(1);
} else if (value instanceof Vector && ((Vector<?>) value).isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -71,7 +71,7 @@ public boolean isSimpleXMLFormat () {
}

public boolean isCollection () {
return isCollection == null ? false : isCollection;
return isCollection != null && isCollection;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -34,7 +34,7 @@ public void addForcedRequiredSystems() {
wasParameterBinding = getSession().getLogin().shouldBindAllParameters();

try {
getSession().getLog().write("WARNING, some JDBC drivers may fail BatchUpdates.");
getSession().getLog().write("WARNING, some JDBC drivers may fail BatchUpdates.\n");
} catch (java.io.IOException e) {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -32,7 +32,7 @@ public void addForcedRequiredSystems() {
DatabasePlatform platform = getSession().getPlatform();

try {
getSession().getLog().write("WARNING, some JDBC drivers may fail BatchUpdates.");
getSession().getLog().write("WARNING, some JDBC drivers may fail BatchUpdates.\n");
} catch (java.io.IOException e) {
}
this.usesBinding = platform.shouldBindAllParameters();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -34,7 +34,7 @@ public void addForcedRequiredSystems() {
wasStatementCaching = platform.shouldCacheAllStatements();

try {
getSession().getLog().write("WARNING, some JDBC drivers may fail BatchUpdates.");
getSession().getLog().write("WARNING, some JDBC drivers may fail BatchUpdates.\n");
} catch (java.io.IOException e) {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -37,7 +37,7 @@ public void addForcedRequiredSystems() {
wasParameterBinding = getSession().getLogin().shouldBindAllParameters();

try {
getSession().getLog().write("WARNING, some JDBC drivers may fail BatchUpdates.");
getSession().getLog().write("WARNING, some JDBC drivers may fail BatchUpdates.\n");
} catch (java.io.IOException e) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class AddJoinedAttributeTest extends AutoVerifyTestCase {
private ReadAllQuery query;
private Vector employees;
private static String EXPECTED_SQL = "SELECT t1.EMP_ID, t2.EMP_ID, t1.F_NAME, t1.GENDER, t1.L_NAME, t2.SALARY, t1.START_TIME, t1.END_TIME, t1.END_DATE, t1.START_DATE, t1.ADDR_ID, t1.MANAGER_ID, t1.VERSION, t0.ADDRESS_ID, t0.CITY, t0.COUNTRY, t0.P_CODE, t0.PROVINCE, t0.STREET FROM EMPLOYEE t1, SALARY t2, ADDRESS t0 WHERE ((t2.EMP_ID = t1.EMP_ID) AND (t0.ADDRESS_ID = t1.ADDR_ID))";
private static String EXPECTED_SQL = "SELECT t1.EMP_ID, t2.EMP_ID, t1.F_NAME, t1.GENDER, t1.L_NAME, t2.SALARY, t1.START_TIME, t1.END_TIME, t1.END_DATE, t1.START_DATE, t1.ADDR_ID, t1.MANAGER_ID, t1.VERSION, t0.ADDRESS_ID, t0.CITY, t0.COUNTRY, t0.P_CODE, t0.PROVINCE, t0.STREET FROM ADDRESS t0, SALARY t2, EMPLOYEE t1 WHERE ((t2.EMP_ID = t1.EMP_ID) AND (t0.ADDRESS_ID = t1.ADDR_ID))";

public AddJoinedAttributeTest() {
setDescription("Test if SQL is reprepared the second time");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
public class AddNonFetchedJoinedAttributeTest extends AutoVerifyTestCase {
private ReadAllQuery query1, query2;
private Vector employees1, employees2;
private static String EXPECTED_SQL1 = "SELECT t1.EMP_ID, t2.EMP_ID, t1.F_NAME, t1.GENDER, t1.L_NAME, t2.SALARY, t1.START_TIME, t1.END_TIME, t1.END_DATE, t1.START_DATE, t1.ADDR_ID, t1.MANAGER_ID, t1.VERSION FROM EMPLOYEE t1, SALARY t2, ADDRESS t0 WHERE ((t2.EMP_ID = t1.EMP_ID) AND (t0.ADDRESS_ID = t1.ADDR_ID))";
private static String EXPECTED_SQL2 = "SELECT t3.EMP_ID, t4.EMP_ID, t3.F_NAME, t3.GENDER, t3.L_NAME, t4.SALARY, t3.START_TIME, t3.END_TIME, t3.END_DATE, t3.START_DATE, t3.ADDR_ID, t3.MANAGER_ID, t3.VERSION FROM EMPLOYEE t3, SALARY t4, EMPLOYEE t1, SALARY t2, ADDRESS t0 WHERE ((t4.EMP_ID = t3.EMP_ID) AND (((t1.EMP_ID = t3.MANAGER_ID) AND (t2.EMP_ID = t1.EMP_ID)) AND (t0.ADDRESS_ID = t1.ADDR_ID)))";
private static String EXPECTED_SQL1 = "SELECT t1.EMP_ID, t2.EMP_ID, t1.F_NAME, t1.GENDER, t1.L_NAME, t2.SALARY, t1.START_TIME, t1.END_TIME, t1.END_DATE, t1.START_DATE, t1.ADDR_ID, t1.MANAGER_ID, t1.VERSION FROM ADDRESS t0, SALARY t2, EMPLOYEE t1 WHERE ((t2.EMP_ID = t1.EMP_ID) AND (t0.ADDRESS_ID = t1.ADDR_ID))";
private static String EXPECTED_SQL2 = "SELECT t3.EMP_ID, t4.EMP_ID, t3.F_NAME, t3.GENDER, t3.L_NAME, t4.SALARY, t3.START_TIME, t3.END_TIME, t3.END_DATE, t3.START_DATE, t3.ADDR_ID, t3.MANAGER_ID, t3.VERSION FROM SALARY t4, EMPLOYEE t3, SALARY t2, EMPLOYEE t1, ADDRESS t0 WHERE ((t4.EMP_ID = t3.EMP_ID) AND (((t1.EMP_ID = t3.MANAGER_ID) AND (t2.EMP_ID = t1.EMP_ID)) AND (t0.ADDRESS_ID = t1.ADDR_ID)))";


public AddNonFetchedJoinedAttributeTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -837,9 +838,9 @@ public void iterate(Expression each) {
getBuilder().assignTableAliasesStartingAt(currentAliasNumber);
}
} else {
for (Iterator iterator1 = allExpressions.iterator();
for (Iterator<Expression> iterator1 = allExpressions.iterator();
iterator1.hasNext();) {
Expression expression = (Expression) iterator1.next();
Expression expression = iterator1.next();
iterator.iterateOn(expression);
}
}
Expand Down Expand Up @@ -952,8 +953,8 @@ public void iterate(Expression each) {
}
};

//we want consistent order in the from and Hashtable nor HashMap guarantee ordering
iterator.setResult(new LinkedHashMap<>(5));
//changing the collection type changes the ordering of aliases
iterator.setResult(new Hashtable<>(5));

if (getWhereClause() != null) {
iterator.iterateOn(getWhereClause());
Expand Down Expand Up @@ -996,8 +997,8 @@ public void iterate(Expression each) {
* no ambiguity
*/
public void computeTablesFromTables() {
//we want consistent order in the from and Hashtable nor HashMap guarantee ordering
Map<DatabaseTable, DatabaseTable> allTables = new LinkedHashMap<>();
//changing the collection type changes the ordering of aliases
Map<DatabaseTable, DatabaseTable> allTables = new Hashtable<>();
AsOfClause asOfClause = null;

if (getBuilder().hasAsOfClause() && !getBuilder().getSession().getProject().hasGenericHistorySupport()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void JPQLAggregateCollectionTests() {
queryEmbed.setParameter(1, "95054");
queryEmbed.getResultList();
Assert.assertEquals(1, _sql.size());
Assert.assertEquals("SELECT t0.CITY FROM SPECEMPLOYEE t1, PREV_ADDRESSES t0 WHERE ((t1.ZIPCODE = ?) AND (t0.SpecEmployee_ID = t1.ID))", _sql.remove(0));
Assert.assertEquals("SELECT t0.CITY FROM PREV_ADDRESSES t0, SPECEMPLOYEE t1 WHERE ((t1.ZIPCODE = ?) AND (t0.SpecEmployee_ID = t1.ID))", _sql.remove(0));
} finally {
if (em.isOpen()) {
em.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public void JPQLTests() {
queryEmbed.setParameter(1, "95051");
queryEmbed.getResultList();
Assert.assertEquals(1, _sql.size());
Assert.assertEquals("SELECT t0.VENDOR FROM SPECEMPLOYEE t1, SPECEMPLOYEE_SPECPHONE t2, SPECPHONE t0 WHERE ((t1.ZIPCODE = ?) AND ((t2.SpecEmployee_ID = t1.ID) AND (t0.ID = t2.phones_ID)))", _sql.remove(0));
Assert.assertEquals("SELECT t0.VENDOR FROM SPECPHONE t0, SPECEMPLOYEE_SPECPHONE t2, SPECEMPLOYEE t1 WHERE ((t1.ZIPCODE = ?) AND ((t2.SpecEmployee_ID = t1.ID) AND (t0.ID = t2.phones_ID)))", _sql.remove(0));

queryEmbed = em.createQuery("SELECT p.vendor FROM SpecEmployee e JOIN e.contactInfo c JOIN c.phones p WHERE e.contactInfo.primaryAddress.zipcode = ?1");
queryEmbed.setParameter(1, "95052");
queryEmbed.getResultList();
Assert.assertEquals(1, _sql.size());
Assert.assertEquals("SELECT t0.VENDOR FROM SPECEMPLOYEE t1, SPECEMPLOYEE_SPECPHONE t2, SPECPHONE t0 WHERE ((t1.ZIPCODE = ?) AND ((t2.SpecEmployee_ID = t1.ID) AND (t0.ID = t2.phones_ID)))", _sql.remove(0));
Assert.assertEquals("SELECT t0.VENDOR FROM SPECPHONE t0, SPECEMPLOYEE_SPECPHONE t2, SPECEMPLOYEE t1 WHERE ((t1.ZIPCODE = ?) AND ((t2.SpecEmployee_ID = t1.ID) AND (t0.ID = t2.phones_ID)))", _sql.remove(0));
} finally {
if (em.isOpen()) {
em.close();
Expand Down

0 comments on commit 9e60c41

Please sign in to comment.