Added isStringColumn method that lets us check whether a column is
a string type and values therefore need to be quoted. Previously, also number values were quoted in SQL queries since neither Oracle nor MySQL seemed to care, but Sybase doesn't like quoted number vaules.
This commit is contained in:
parent
00a396c2f5
commit
802d66ee80
1 changed files with 20 additions and 2 deletions
|
@ -594,7 +594,7 @@ public class DbMapping implements Updatable {
|
|||
public synchronized Schema getSchema () throws ClassNotFoundException, SQLException, DataSetException {
|
||||
if (!isRelational ())
|
||||
throw new SQLException ("Can't get Schema for non-relational data mapping");
|
||||
if (source == null && parentMapping != null)
|
||||
if (source == null && parentMapping != null)
|
||||
return parentMapping.getSchema ();
|
||||
// Use local variable s to avoid synchronization (schema may be nulled elsewhere)
|
||||
Schema s = schema;
|
||||
|
@ -604,6 +604,24 @@ public class DbMapping implements Updatable {
|
|||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public boolean isStringColumn (String columnName) throws SQLException {
|
||||
try {
|
||||
Schema s = getSchema ();
|
||||
if (s == null)
|
||||
throw new SQLException ("Error retrieving relational schema for "+this);
|
||||
Column c = s.getColumn (columnName);
|
||||
if (c == null)
|
||||
throw new SQLException ("Column "+columnName+" not found in "+this);
|
||||
return c.isString ();
|
||||
} catch (Exception x) {
|
||||
throw new SQLException (x.getMessage ());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Village Schema object for this DbMapping.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue