From ec76d4d29f3c96d48dfc84144ff323167c43d8c5 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 24 Oct 2008 05:18:50 +0000 Subject: [PATCH] Oops, avoid introducing a bug when nulls == zeros == values.length. We want to return null in that case. --- .../samskivert/jdbc/depot/DepotMarshaller.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java index fc3112e..22f1819 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java +++ b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java @@ -367,15 +367,18 @@ public class DepotMarshaller } } - // make sure the keys are all null or all non-null; we also allow primary keys where - // there are zero-valued primitive primary key columns as along as there is at least - // one non-zero valued additional key column; this is a compromise that allows sensible - // things like (id=99, type=0) but unfortunately also allows less sensible things like - // (id=0, type=5) while continuing to disallow the dangerous (id=0) - if (nulls == 0 || (nulls == zeros)) { + // make sure the keys are all null or all non-null + if (nulls == 0) { return makePrimaryKey(values); } else if (nulls == values.length) { return null; + } else if (nulls == zeros) { + // we also allow primary keys where there are zero-valued primitive primary key + // columns as along as there is at least one non-zero valued additional key column; + // this is a compromise that allows sensible things like (id=99, type=0) but + // unfortunately also allows less sensible things like (id=0, type=5) while + // continuing to disallow the dangerous (id=0) + return makePrimaryKey(values); } // throw an informative error message