Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9e9f3d4
Fix all int tests.
BrunoSMonteiro74 Nov 21, 2024
30f66d7
Fix Postgres TestPostgreSQLDialect.expectedBlobLiteral to NOT use E'\…
BrunoSMonteiro74 Dec 4, 2024
1422ab2
Added method DatabaseMetaDataProvider.getPartitionedTables, and on Po…
BrunoSMonteiro74 Dec 4, 2024
178ccbc
Fix TestSqlStatements.testBlobFields for H2 and Oracle.
BrunoSMonteiro74 Dec 4, 2024
a010d49
Add coverage to partition tables.
BrunoSMonteiro74 Dec 7, 2024
862e8a2
Add methods Schema.partitionedTableNames and Schema.partitionTableNames.
BrunoSMonteiro74 Dec 8, 2024
4c4ca2f
Add extra coverage to changed code.
BrunoSMonteiro74 Dec 8, 2024
35ab449
Add TestSqlStatements.testBlobFieldsRealBinary to encode and read rea…
BrunoSMonteiro74 Dec 8, 2024
bf047dd
Remove extraneous comment.
BrunoSMonteiro74 Dec 8, 2024
c51e18c
Remove unnecessary test method.
BrunoSMonteiro74 Dec 8, 2024
dc1fa5b
Clear sonar items.
BrunoSMonteiro74 Dec 8, 2024
b0266b9
WEB-161904 move properties from Schema to AdditionalMetadata.
BrunoSMonteiro74 Feb 27, 2025
7592278
Merge branch 'main' of github.com:alfasoftware/morf into feature/igno…
BrunoSMonteiro74 Feb 27, 2025
d7fadd5
Merge from main and fix test TestDatabaseMetaDataProvider.testTableWi…
BrunoSMonteiro74 Feb 25, 2026
babd7e3
Revert morf.properties change
BrunoSMonteiro74 Feb 25, 2026
f33a5a4
Remove unnecessary changes
BrunoSMonteiro74 Mar 2, 2026
2935597
Remove unnecessary changes #2
BrunoSMonteiro74 Mar 2, 2026
a98fc77
Remove unusable import
BrunoSMonteiro74 Mar 2, 2026
0bef89b
Solve comments from Juraj
BrunoSMonteiro74 Apr 21, 2026
865b0e2
Fix failing tests
BrunoSMonteiro74 Apr 21, 2026
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 @@ -32,6 +32,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand All @@ -56,6 +57,7 @@
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;

/**
Expand Down Expand Up @@ -116,6 +118,8 @@
private final LoadingCache<AName, Sequence> sequenceCache = CacheBuilder.newBuilder().build(CacheLoader.from(this::loadSequence));

private final Supplier<Map<String, String>> databaseInformation = Suppliers.memoize(this::loadDatabaseInformation);
protected Supplier<Set<RealName>> ignoredPartitionTables = Suppliers.memoize(this::loadIgnoredPartitionTables);
protected Supplier<Set<RealName>> partitionedTables = Suppliers.memoize(this::loadPartitionedTables);

/**
* @param connection The database connection from which meta data should be provided.
Expand Down Expand Up @@ -148,6 +152,9 @@
}
}

protected Set<RealName> loadIgnoredPartitionTables() { return ImmutableSet.of(); }

protected Set<RealName> loadPartitionedTables() { return ImmutableSet.of(); }

/**
* @see org.alfasoftware.morf.metadata.Schema#isEmptyDatabase()
Expand Down Expand Up @@ -306,6 +313,10 @@
throw new RuntimeSqlException("Error reading metadata for table ["+tableName+"]", e);
}
}
// add partitioned tables to list
partitionedTables.get().forEach(table -> {

Check warning on line 317 in morf-core/src/main/java/org/alfasoftware/morf/jdbc/DatabaseMetaDataProvider.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove useless curly braces around statement

See more on https://sonarcloud.io/project/issues?id=org.alfasoftware%3Amorf-parent&issues=AZ2wXlvRe5TyMIfjQntt&open=AZ2wXlvRe5TyMIfjQntt&pullRequest=333
tableNameMappings.put(table, table);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering, these get ignored via isIgnoredTable() and therefore then have to be added back? Why?

If we add support for Oracle's partitioning, this might become problematic, unless Oracle also excludes those tables during the above and will need us to also add those tables here.

@BrunoSMonteiro74 BrunoSMonteiro74 Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tables are not added back. We have two types of tables related to partitions in postgres: The Partitioned table MEASURE(id, a, b) PARTITION by ID -- not ignored, need to be added because the default java API for reading tables in Postgres driver ignores them
and the partition tables
MEASURE_P1 (id, a, b) FOR VALUES ('0) TO ('37000') -- ignored, the partitions themselves.


long end = System.currentTimeMillis();
Map<AName, RealName> tableNameMap = tableNameMappings.build();
Expand Down Expand Up @@ -389,8 +400,8 @@
* @param tableName The table which we are accessing.
* @return <var>true</var> if the table should be ignored, false otherwise.
*/
protected boolean isIgnoredTable(@SuppressWarnings("unused") RealName tableName) {
return false;
protected boolean isIgnoredTable(RealName tableName) {
return ignoredPartitionTables.get().contains(tableName);
}


Expand Down Expand Up @@ -1129,22 +1140,16 @@
protected void runSQL(String sql, String schemaName, ResultSetHandler handler) {
if (log.isTraceEnabled()) log.trace("runSQL: " + sql);
try {
PreparedStatement statement = connection.prepareStatement(sql);
try {
try (PreparedStatement statement = connection.prepareStatement(sql)) {

// pass through the schema name
if (schemaName != null && !schemaName.isBlank()) {
statement.setString(1, schemaName);
}

ResultSet resultSet = statement.executeQuery();
try {
try (ResultSet resultSet = statement.executeQuery()) {
handler.handle(resultSet);
} finally {
resultSet.close();
}
} finally {
statement.close();
}
} catch (SQLException sqle) {
throw new RuntimeSqlException("Error running SQL: " + sql, sqle);
Expand Down Expand Up @@ -1196,7 +1201,7 @@
* @return {@link RealName} instance holding the two name versions.
* Can also be used as a key in the lookup maps, like {@link AName}.
*/
protected static RealName createRealName(String dbName, String realName) {
public static RealName createRealName(String dbName, String realName) {
return new RealName(dbName, realName);
}

Expand All @@ -1210,7 +1215,7 @@
* see {@link DatabaseMetaDataProvider#named(String)}
* and {@link DatabaseMetaDataProvider#createRealName(String, String)}
*/
protected static class AName {
public static class AName {
private final String aName;
private final int hashCode;

Expand Down Expand Up @@ -1255,11 +1260,11 @@
* see {@link DatabaseMetaDataProvider#named(String)}
* and {@link DatabaseMetaDataProvider#createRealName(String, String)}
*/
protected static final class RealName extends AName {
public static final class RealName extends AName {

private final String realName;

private RealName(String dbName, String realName) {
public RealName(String dbName, String realName) {
super(dbName);
this.realName = realName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.alfasoftware.morf.jdbc.DatabaseMetaDataProvider;
import org.apache.commons.lang3.NotImplementedException;

/**
Expand All @@ -18,6 +20,26 @@ default Map<String, String> primaryKeyIndexNames() {
throw new NotImplementedException("Not implemented yet.");
}

/**
* Provides the names of all partitioned tables in the database. This applies for now for postgres. Note that the order of
* the tables in the result is not specified. The case of the
* table names may be preserved when logging progress, but should not be relied on for schema
* processing. A partitioned table is a table that has partitions.
*
* @return A collection of all partitioned table names available in the database.
*/
default Set<DatabaseMetaDataProvider.RealName> partitionedTableNames() { throw new NotImplementedException("Not implemented yet."); }

/**
* Provides the names of all partition tables in the database. This applies for now for postgres. Note that the order of
* the tables in the result is not specified. The case of the
* table names may be preserved when logging progress, but should not be relied on for schema
* processing. A partition table is a table that is a partition of a partitioned table.
*
* @return A collection of all partition table names available in the database.
*/
default Set<DatabaseMetaDataProvider.RealName> partitionTableNames() { throw new NotImplementedException("Not implemented yet."); }

default Map<String, List<Index>> ignoredIndexes() {
return Map.of();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.when;


/**
* Test class for {@link H2MetaDataProvider}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,8 @@ public void testUpdateOfMissingFieldThrowingException() {
() -> verifyUpgrade(expected, List.of(UpdateId.class, DropPrimaryKey.class, UpdateMissingField.class, AddColumn.class, UpdateField.class)));

assertThat(exception.getMessage(), containsString("Error executing SQL"));
assertThat(exception.getMessage(), containsString("UPDATE WithDefaultValue SET missingColumn"));
assertThat(exception.getMessage(), containsString("UPDATE"));
assertThat(exception.getMessage(), containsString("WithDefaultValue SET missingColumn"));
}


Expand Down
Loading