From 030b1109019a49e70afe8ce83e4fcbcbd3ce0733 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Fri, 18 Jul 2008 03:25:19 +0000 Subject: [PATCH] Better column type translation for very large MEMO/OLE types in the Database.copyTable logic git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@360 f203690c-595d-4dc9-a70b-905162fa7fd2 --- src/changes/changes.xml | 4 ++++ src/java/com/healthmarketscience/jackcess/DataType.java | 6 ++++-- .../java/com/healthmarketscience/jackcess/ImportTest.java | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index e577cda..3d2dcf9 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -10,6 +10,10 @@ Reserve minimum space for memo/ole fields so that greedy inline row usage does not cause spurious write failures for wide tables. + + Better column type translation for very large MEMO/OLE types in the + Database.copyTable logic. + diff --git a/src/java/com/healthmarketscience/jackcess/DataType.java b/src/java/com/healthmarketscience/jackcess/DataType.java index f648fde..8e08bec 100644 --- a/src/java/com/healthmarketscience/jackcess/DataType.java +++ b/src/java/com/healthmarketscience/jackcess/DataType.java @@ -377,9 +377,11 @@ public enum DataType { // make sure size is reasonable int size = lengthInUnits * rtn.getUnitSize(); if(rtn.isVariableLength() && !rtn.isValidSize(size)) { - // try alternate type + // try alternate type. we always accept alternate "long value" types + // regardless of the given lengthInUnits DataType altRtn = ALT_SQL_TYPES.get(sqlType); - if((altRtn != null) && altRtn.isValidSize(size)) { + if((altRtn != null) && + (altRtn.isLongValue() || altRtn.isValidSize(size))) { // use alternate type rtn = altRtn; } diff --git a/test/src/java/com/healthmarketscience/jackcess/ImportTest.java b/test/src/java/com/healthmarketscience/jackcess/ImportTest.java index a2a4719..ad2c851 100644 --- a/test/src/java/com/healthmarketscience/jackcess/ImportTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/ImportTest.java @@ -74,6 +74,7 @@ public class ImportTest extends TestCase rs.addColumn(Types.BINARY, "col4", 128, 0, 0); rs.addColumn(Types.BINARY, "col5", 512, 0, 0); rs.addColumn(Types.NUMERIC, "col6", 0, 7, 15); + rs.addColumn(Types.VARCHAR, "col7", Integer.MAX_VALUE, 0, 0); Database db = create(); db.copyTable("Test1", (ResultSet)Proxy.newProxyInstance( @@ -83,7 +84,7 @@ public class ImportTest extends TestCase Table t = db.getTable("Test1"); List columns = t.getColumns(); - assertEquals(6, columns.size()); + assertEquals(7, columns.size()); Column c = columns.get(0); assertEquals("col1", c.getName()); @@ -116,6 +117,11 @@ public class ImportTest extends TestCase assertEquals(7, c.getScale()); assertEquals(15, c.getPrecision()); + c = columns.get(6); + assertEquals("col7", c.getName()); + assertEquals(DataType.MEMO, c.getType()); + assertEquals(0, c.getLength()); + } -- 2.39.5