From 12e5fd0846f33a149c6b1bd0b7458514a842d456 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 26 Mar 2002 15:19:52 +0000 Subject: [PATCH] Make lookups by column name case insensitive. Also, hide the column to property map from the outside world so nobody can do a case sensitive lookup by fault. --- src/helma/objectmodel/db/DbMapping.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/helma/objectmodel/db/DbMapping.java b/src/helma/objectmodel/db/DbMapping.java index 33347c6b..2c7e9043 100644 --- a/src/helma/objectmodel/db/DbMapping.java +++ b/src/helma/objectmodel/db/DbMapping.java @@ -8,6 +8,7 @@ import helma.util.Updatable; import helma.util.SystemProperties; import java.util.HashMap; import java.util.Enumeration; +import java.util.Iterator; import java.util.StringTokenizer; import java.sql.*; import com.workingdogs.village.*; @@ -95,7 +96,7 @@ public class DbMapping implements Updatable { parent = null; // subnodes = null; // properties = null; - idField = "id"; + idField = "ID"; } /** @@ -112,7 +113,7 @@ public class DbMapping implements Updatable { parent = null; // subnodes = null; // properties = null; - idField = "id"; + idField = "ID"; this.props = props; update (); @@ -160,7 +161,7 @@ public class DbMapping implements Updatable { } // id field must not be null, default is "id" - idField = props.getProperty ("_id", "id"); + idField = props.getProperty ("_id", "ID"); nameField = props.getProperty ("_name"); @@ -212,7 +213,7 @@ public class DbMapping implements Updatable { if (rel.columnName != null && (rel.reftype == Relation.PRIMITIVE || rel.reftype == Relation.REFERENCE)) - d2p.put (rel.columnName, rel); + d2p.put (rel.columnName.toUpperCase (), rel); // app.logEvent ("Mapping "+propName+" -> "+dbField); } } catch (Exception x) { @@ -396,7 +397,7 @@ public class DbMapping implements Updatable { return null; if (table == null && parentMapping != null) return parentMapping.columnNameToProperty (columnName); - Relation rel = (Relation) db2prop.get (columnName); + Relation rel = (Relation) db2prop.get (columnName.toUpperCase ()); if (rel != null && (rel.reftype == Relation.PRIMITIVE || rel.reftype == Relation.REFERENCE)) return rel.propName; return null; @@ -424,7 +425,7 @@ public class DbMapping implements Updatable { return null; if (table == null && parentMapping != null) return parentMapping.columnNameToRelation (columnName); - return (Relation) db2prop.get (columnName); + return (Relation) db2prop.get (columnName.toUpperCase ()); } /** @@ -670,10 +671,10 @@ public class DbMapping implements Updatable { return prop2db; } - public HashMap getDB2Prop () { + public Iterator getDBPropertyIterator () { if (table == null && parentMapping != null) - return parentMapping.getDB2Prop (); - return db2prop; + return parentMapping.getDBPropertyIterator (); + return db2prop.values ().iterator (); } /**