Patch from Zell to quell warnings about mismatched schemas for database-

specific auxiliary columns (specifically Postgres's FTS column).
This commit is contained in:
Michael Bayne
2007-08-13 19:37:09 +00:00
parent 9b87020fe5
commit f4dfccbf97
4 changed files with 28 additions and 3 deletions
@@ -590,7 +590,7 @@ public class DepotMarshaller<T extends PersistentRecord>
// if the table exists, see if should attempt automatic schema migration
if (_schemaVersion < 0) {
// nope, versioning disabled
verifySchemasMatch(metaData, ctx);
verifySchemasMatch(metaData, ctx, builder);
return;
}
@@ -613,7 +613,7 @@ public class DepotMarshaller<T extends PersistentRecord>
});
if (currentVersion == _schemaVersion) {
verifySchemasMatch(metaData, ctx);
verifySchemasMatch(metaData, ctx, builder);
return;
}
@@ -813,7 +813,8 @@ public class DepotMarshaller<T extends PersistentRecord>
/**
* Checks that there are no database columns for which we no longer have Java fields.
*/
protected void verifySchemasMatch (TableMetaData meta, PersistenceContext ctx)
protected void verifySchemasMatch (
TableMetaData meta, PersistenceContext ctx, SQLBuilder builder)
throws PersistenceException
{
for (String fname : _columnFields) {
@@ -821,6 +822,9 @@ public class DepotMarshaller<T extends PersistentRecord>
meta.tableColumns.remove(fmarsh.getColumnName());
}
for (String column : meta.tableColumns) {
if (builder.isPrivateColumn(column)) {
continue;
}
log.warning(getTableName() + " contains stale column '" + column + "'.");
}
}
@@ -160,6 +160,13 @@ public class MySQLBuilder
return true;
}
@Override
public boolean isPrivateColumn (String column)
{
// The MySQL builder does not yet have any private columns.
return false;
}
@Override
protected BuildVisitor getBuildVisitor ()
{
@@ -173,6 +173,13 @@ public class PostgreSQLBuilder
return true;
}
@Override
public boolean isPrivateColumn (String column)
{
// filter out any column that we created as part of FTS support
return column.startsWith("ftsCol_");
}
@Override
protected BuildVisitor getBuildVisitor ()
{
@@ -179,6 +179,13 @@ public abstract class SQLBuilder
Connection conn, DepotMarshaller<T> marshaller, FullTextIndex fts)
throws SQLException;
/**
* Return true if the supplied column is an internal consideration of this {@link SQLBuilder},
* e.g. PostgreSQL's full text search data is stored in a table column that should otherwise
* not be visible to Depot; this method helps mask it.
*/
public abstract boolean isPrivateColumn (String column);
/**
* Overridden by subclasses to create a dialect-specific {@link BuildVisitor}.
*/