You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/12/21 12:09:38 UTC
svn commit: r1221678 - in
/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database:
DBInterfaceMySQL.java Database.java
Author: kwright
Date: Wed Dec 21 11:09:37 2011
New Revision: 1221678
URL: http://svn.apache.org/viewvc?rev=1221678&view=rev
Log:
Another fix, this time disabling character truncation, looks like a mysql jdbc driver bug
Modified:
incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java?rev=1221678&r1=1221677&r2=1221678&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java (original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java Wed Dec 21 11:09:37 2011
@@ -260,7 +260,7 @@ public class DBInterfaceMySQL extends Da
{
queryBuffer.append(columnName);
queryBuffer.append(' ');
- queryBuffer.append(cd.getTypeString());
+ queryBuffer.append(mapType(cd.getTypeString()));
if (forceNull || cd.getIsNull())
queryBuffer.append(" NULL");
else
@@ -281,6 +281,19 @@ public class DBInterfaceMySQL extends Da
}
}
+ /** Map a standard type into a derby type.
+ *@param inputType is the input type.
+ *@return the output type.
+ */
+ protected static String mapType(String inputType)
+ {
+ if (inputType.equalsIgnoreCase("float"))
+ return "DOUBLE";
+ if (inputType.equalsIgnoreCase("blob"))
+ return "LONGBLOB";
+ return inputType;
+ }
+
/** Perform a table alter operation.
*@param tableName is the name of the table to alter.
*@param columnMap is the map describing the columns and types to add. These
@@ -559,10 +572,14 @@ public class DBInterfaceMySQL extends Da
boolean isPrimaryKey = primaryKey.equals(fieldName);
boolean isNull = isNullable.equals("YES");
String dataType;
- if (type.equals("CHARACTER VARYING"))
+ if (type.equals("VARCHAR"))
dataType = "VARCHAR("+width.toString()+")";
- else if (type.equals("CLOB"))
- dataType = "LONGVARCHAR";
+ else if (type.equals("CHAR"))
+ dataType = "CHAR("+width.toString()+")";
+ else if (type.equals("LONGBLOB"))
+ dataType = "BLOB";
+ else if (type.equals("DOUBLE PRECISION"))
+ dataType = "FLOAT";
else
dataType = type;
rval.put(fieldName,new ColumnDescription(type,isPrimaryKey,isNull,null,null,false));
Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java?rev=1221678&r1=1221677&r2=1221678&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java (original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java Wed Dec 21 11:09:37 2011
@@ -1149,6 +1149,7 @@ public abstract class Database
{
try
{
+ //System.out.println(" Column "+rsmd.getColumnLabel(col)+" is of type "+rsmd.getColumnType(col));
if (isBLOB(rsmd,col))
{
// System.out.println("It's a blob!");
@@ -1177,8 +1178,9 @@ public abstract class Database
java.sql.Date date;
Clob clob;
String resultString;
-
- switch (rsmd.getColumnType(col))
+
+ int colType = rsmd.getColumnType(col);
+ switch (colType)
{
case java.sql.Types.CHAR :
case java.sql.Types.VARCHAR :
@@ -1188,7 +1190,7 @@ public abstract class Database
case ResultSpecification.FORM_STRING:
if ((resultString = rs.getString(col)) != null)
{
- if (rsmd.getColumnDisplaySize(col) < resultString.length())
+ if (colType == java.sql.Types.VARCHAR && rsmd.getColumnDisplaySize(col) < resultString.length())
{
result = resultString.substring(0,rsmd.getColumnDisplaySize(col));
}