From 1f7d58d290f5aea0758528bb3a72f465a2418991 Mon Sep 17 00:00:00 2001 From: mdb Date: Mon, 13 Aug 2007 19:37:09 +0000 Subject: [PATCH] Patch from Zell to quell warnings about mismatched schemas for database- specific auxiliary columns (specifically Postgres's FTS column). git-svn-id: https://samskivert.googlecode.com/svn/trunk@2166 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/jdbc/depot/DepotMarshaller.java | 10 +++++++--- src/java/com/samskivert/jdbc/depot/MySQLBuilder.java | 7 +++++++ .../com/samskivert/jdbc/depot/PostgreSQLBuilder.java | 7 +++++++ src/java/com/samskivert/jdbc/depot/SQLBuilder.java | 7 +++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java index c066c442..b6de2d18 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java +++ b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java @@ -590,7 +590,7 @@ public class DepotMarshaller // 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 }); if (currentVersion == _schemaVersion) { - verifySchemasMatch(metaData, ctx); + verifySchemasMatch(metaData, ctx, builder); return; } @@ -813,7 +813,8 @@ public class DepotMarshaller /** * 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 meta.tableColumns.remove(fmarsh.getColumnName()); } for (String column : meta.tableColumns) { + if (builder.isPrivateColumn(column)) { + continue; + } log.warning(getTableName() + " contains stale column '" + column + "'."); } } diff --git a/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java b/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java index b522ef04..5019e670 100644 --- a/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java +++ b/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java @@ -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 () { diff --git a/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java b/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java index a102fb49..92b557b6 100644 --- a/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java +++ b/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java @@ -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 () { diff --git a/src/java/com/samskivert/jdbc/depot/SQLBuilder.java b/src/java/com/samskivert/jdbc/depot/SQLBuilder.java index f6d80475..9295155e 100644 --- a/src/java/com/samskivert/jdbc/depot/SQLBuilder.java +++ b/src/java/com/samskivert/jdbc/depot/SQLBuilder.java @@ -179,6 +179,13 @@ public abstract class SQLBuilder Connection conn, DepotMarshaller 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}. */