From fe40e763287b625a71e08fc88c06d5a7c69e438a Mon Sep 17 00:00:00 2001 From: Eric Long Date: Mon, 27 Nov 2023 14:35:05 -0500 Subject: [PATCH] 0006127: Dbfill of nchar/nvarchar and avoid timestamp/rowversion --- .../jumpmind/symmetric/io/data/DbFill.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/DbFill.java b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/DbFill.java index cbf167a1a2..74627fd2ae 100644 --- a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/DbFill.java +++ b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/DbFill.java @@ -170,6 +170,7 @@ public void fillTables(String[] tableNames, Map tableProperti Table table = platform.readTableFromDatabase(getCatalogToUse(), getSchemaToUse(), tableName); if (table != null) { + table = filterColumns(table); tablesToFill.add(table); } else if (!ignoreMissingTables) { throw new RuntimeException("Cannot find table " + tableName + " in catalog " @@ -889,7 +890,8 @@ private Object generateRandomValueForColumn(Table table, Column column) { objectValue = randomBytes(randomSize(column, size)); } else if (type == Types.ARRAY) { objectValue = null; - } else if (type == Types.VARCHAR || type == Types.LONGVARCHAR || type == Types.CHAR || type == Types.CLOB) { + } else if (type == Types.VARCHAR || type == Types.NVARCHAR || type == Types.NCHAR || type == Types.LONGVARCHAR || type == Types.CHAR + || type == Types.CLOB) { if (column.getJdbcTypeName() != null && (column.getJdbcTypeName().equals("JSON") || column.getJdbcTypeName().equals("jsonb"))) { objectValue = "{\"jumpmind\":\"symmetricds\"}"; @@ -1054,6 +1056,7 @@ protected Map getAllDbTables() { allDbTablesCache = new TreeMap(String.CASE_INSENSITIVE_ORDER); Table[] allTables = platform.readDatabase(getCatalogToUse(), getSchemaToUse(), null).getTables(); for (Table table : allTables) { + table = filterColumns(table); allDbTablesCache.put(table.getName(), table); } } @@ -1064,6 +1067,25 @@ protected Table getDbTable(String catalogName, String schemaName, String tableNa Table table = getAllDbTables().get(tableName); if (table == null) { table = platform.readTableFromDatabase(catalogName, schemaName, tableName); + table = filterColumns(table); + } + return table; + } + + protected Table filterColumns(Table table) { + if (platform.getName().startsWith("mssql")) { + List columnsToRemove = new ArrayList(); + for (Column column : table.getColumns()) { + if (column.getJdbcTypeName().equalsIgnoreCase("timestamp") || column.getJdbcTypeName().equalsIgnoreCase("rowversion")) { + columnsToRemove.add(column); + } + } + if (columnsToRemove.size() > 0) { + table = table.copy(); + for (Column column : columnsToRemove) { + table.removeColumn(column); + } + } } return table; }