From 8d35255716daa3be978e257a3263ba4514321023 Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 6 Sep 2002 14:09:11 +0000 Subject: [PATCH] Renamed DbMapping.isStringColumn() method to DbMapping.needsQuotes and included DATE, TIME and TIMESTAMP in the list of types that need to be quoted. --- src/helma/objectmodel/db/DbMapping.java | 21 +++++++++++++++++---- src/helma/objectmodel/db/Relation.java | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/helma/objectmodel/db/DbMapping.java b/src/helma/objectmodel/db/DbMapping.java index e16c5a08..543bf6c7 100644 --- a/src/helma/objectmodel/db/DbMapping.java +++ b/src/helma/objectmodel/db/DbMapping.java @@ -568,10 +568,10 @@ public final class DbMapping implements Updatable { } /** - * Return true if the column identified by the parameter is a string type. This is - * used in query building to determine if a value needs to be quoted. + * Return true if values for the column identified by the parameter need + * to be quoted in SQL queries. */ - public boolean isStringColumn (String columnName) throws SQLException { + public boolean needsQuotes (String columnName) throws SQLException { try { Schema s = getSchema (); if (s == null) @@ -579,7 +579,20 @@ public final class DbMapping implements Updatable { Column c = s.getColumn (columnName); if (c == null) throw new SQLException ("Column "+columnName+" not found in "+this); - return c.isString () || c.isVarBinary () || c.isLongVarBinary (); + switch (c.typeEnum()) { + case Types.CHAR: + case Types.VARCHAR: + case Types.LONGVARCHAR: + case Types.BINARY: + case Types.VARBINARY: + case Types.LONGVARBINARY: + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + return true; + default: + return false; + } } catch (Exception x) { throw new SQLException (x.getMessage ()); } diff --git a/src/helma/objectmodel/db/Relation.java b/src/helma/objectmodel/db/Relation.java index 776a735b..c3cc2780 100644 --- a/src/helma/objectmodel/db/Relation.java +++ b/src/helma/objectmodel/db/Relation.java @@ -367,7 +367,7 @@ public final class Relation { q.append (accessColumn); q.append (" = "); // check if column is string type and value needs to be quoted - if (otherType.isStringColumn (accessColumn)) { + if (otherType.needsQuotes (accessColumn)) { q.append ("'"); q.append (escape (kstr)); q.append ("'"); @@ -554,7 +554,7 @@ public final class Relation { } q.append (foreignName); q.append (" = "); - if (otherType.isStringColumn (foreignName)) { + if (otherType.needsQuotes (foreignName)) { q.append ("'"); q.append (escape (local)); q.append ("'");