From b0bc33f822e48f5973fd9f41cc123343ff5a8d02 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Tue, 5 Jun 2007 02:21:55 +0000 Subject: [PATCH] handle reading/writing numeric values which thing that they are fixed length fields (fix #1672071) git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@148 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../healthmarketscience/jackcess/Column.java | 5 ++ .../jackcess/DataType.java | 2 +- test/data/fixedNumericTest.mdb | Bin 0 -> 131072 bytes .../jackcess/DatabaseTest.java | 52 ++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 test/data/fixedNumericTest.mdb diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java index 033e933..b9dc208 100644 --- a/src/java/com/healthmarketscience/jackcess/Column.java +++ b/src/java/com/healthmarketscience/jackcess/Column.java @@ -924,6 +924,11 @@ public class Column implements Comparable { case GUID: writeGUIDValue(buffer, obj); break; + case NUMERIC: + // yes, that's right, occasionally numeric values are written as fixed + // length... + writeNumericValue(buffer, obj); + break; default: throw new IOException("Unsupported data type: " + getType()); } diff --git a/src/java/com/healthmarketscience/jackcess/DataType.java b/src/java/com/healthmarketscience/jackcess/DataType.java index a19f374..eac9bd8 100644 --- a/src/java/com/healthmarketscience/jackcess/DataType.java +++ b/src/java/com/healthmarketscience/jackcess/DataType.java @@ -58,7 +58,7 @@ public enum DataType { UNKNOWN_0D((byte) 0x0D), GUID((byte) 0x0F, null, 16), // for some reason numeric is "var len" even though it has a fixed size... - NUMERIC((byte) 0x10, Types.NUMERIC, null, true, false, 17, 17, 17, + NUMERIC((byte) 0x10, Types.NUMERIC, 17, true, false, 17, 17, 17, true, 0, 0, 28, 1, 18, 28, 1); /** Map of SQL types to Access data types */ diff --git a/test/data/fixedNumericTest.mdb b/test/data/fixedNumericTest.mdb new file mode 100644 index 0000000000000000000000000000000000000000..e329181090b592e8b6ac79c541434adb5ce4666c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`k*04|!Ee7F)2`*2gw4D|KZ-9=!lZ$LEIi3$B>pSVLL!`PHAXiS;9PY zHEpIYgjT^`l0evAq#C8IO2af3o#pd$rCFF4f3=Fw?TQDyVc;THjeQRq5k$7du)pd06wQuafxrAq1pcL3Zp77nnTB!z`5j4NAO zIb<02*I^tjdrBp89fg#=h|jfqAwMyB>~TdF@Yr*TlT%t3G=DBTJrcVVYge zTFhr(yyTtFzI6MaT0i@tJATr&Bhkle8VjW`2E600SRO zQ(XMh=+B1#_>q=(*1UaLkAI+O>J%&N6gSiiuK4Q1i`U$B&)`kBEqUb0sZ%Hzk?IpQ z&uo6rLf_g)?t7`dV%x7@J9P@)VR$m<15?`ya^a{>lQ(BJ7m`uxLE|p0fI-AH(1afA^6>^o5TTQMo?FG$d2W}f>Orf5HY?^I>m(RAq6*Cjax1=Sg!Ep+y4wSnb?&7S; zlJ%;~*{wRSH1WD0o)=}uZHm7J3kZWTju}EZrjU|k-OpkwvWfN-BF?#A-A%ctUx$9T3)~Ir zZjeMShye+Fw^@Ynoc($WILT~(?Zq8;FZ3QpOh0;N)?zpAd>m(?U5W%`S?^)ZSM-&gh1LCAip;<82%;?(2#@hj2zt=i1h-xnRN)JFzpuknTB7Hgm#hN&6( ztiTbSt=mNCeQ3$t@wz}SModnnmhaef5%|A`5t;eLpbeW};-EdC*>N21%yk^@%r(Ev OL6 row = t.getNextRow(); + assertEquals("some data", row.get("col1")); + assertEquals(new BigDecimal("1"), row.get("col2")); + assertEquals(new BigDecimal("0"), row.get("col3")); + assertEquals(new BigDecimal("0"), row.get("col4")); + assertEquals(new BigDecimal("4"), row.get("col5")); + assertEquals(new BigDecimal("-1"), row.get("col6")); + assertEquals(new BigDecimal("1"), row.get("col7")); + + Object[] tmpRow = new Object[]{ + "foo", new BigDecimal("1"), new BigDecimal(3), new BigDecimal("13"), + new BigDecimal("-17"), new BigDecimal("0"), new BigDecimal("8734")}; + t.addRow(tmpRow); + t.reset(); + + t.getNextRow(); + row = t.getNextRow(); + assertEquals(tmpRow[0], row.get("col1")); + assertEquals(tmpRow[1], row.get("col2")); + assertEquals(tmpRow[2], row.get("col3")); + assertEquals(tmpRow[3], row.get("col4")); + assertEquals(tmpRow[4], row.get("col5")); + assertEquals(tmpRow[5], row.get("col6")); + assertEquals(tmpRow[6], row.get("col7")); + + db.close(); + + } + public void testMultiPageTableDef() throws Exception { List columns = open().getTable("Table2").getColumns(); -- 2.39.5