[ 1746898 ] Error DB_PostgreSQL.convertStatement with ''
This commit is contained in:
parent
ae6380c79f
commit
8094eec76e
|
@ -88,6 +88,8 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
else if (isCreate && cmpString.indexOf(" VIEW ") != -1)
|
else if (isCreate && cmpString.indexOf(" VIEW ") != -1)
|
||||||
;
|
;
|
||||||
else if (cmpString.indexOf("ALTER TABLE") != -1) {
|
else if (cmpString.indexOf("ALTER TABLE") != -1) {
|
||||||
|
statement = recoverQuotedStrings(statement, retVars);
|
||||||
|
retVars.clear();
|
||||||
statement = convertDDL(convertComplexStatement(statement));
|
statement = convertDDL(convertComplexStatement(statement));
|
||||||
/*
|
/*
|
||||||
} else if (cmpString.indexOf("ROWNUM") != -1) {
|
} else if (cmpString.indexOf("ROWNUM") != -1) {
|
||||||
|
@ -103,7 +105,8 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
} else {
|
} else {
|
||||||
statement = convertComplexStatement(convertAlias(statement));
|
statement = convertComplexStatement(convertAlias(statement));
|
||||||
}
|
}
|
||||||
statement = recoverQuotedStrings(statement, retVars);
|
if (retVars.size() > 0)
|
||||||
|
statement = recoverQuotedStrings(statement, retVars);
|
||||||
result.add(statement);
|
result.add(statement);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -993,7 +996,8 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
} else if (action.equals(" MODIFY "))
|
} else if (action.equals(" MODIFY "))
|
||||||
{
|
{
|
||||||
rest = rest.trim();
|
rest = rest.trim();
|
||||||
if (rest.toUpperCase().startsWith("NOT ") || rest.toUpperCase().startsWith("NULL "))
|
if (rest.toUpperCase().startsWith("NOT ") || rest.toUpperCase().startsWith("NULL ")
|
||||||
|
|| rest.toUpperCase().equals("NULL") || rest.toUpperCase().equals("NOT NULL"))
|
||||||
{
|
{
|
||||||
type = null;
|
type = null;
|
||||||
}
|
}
|
||||||
|
@ -1016,60 +1020,24 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
|
||||||
rest = "";
|
rest = "";
|
||||||
}
|
}
|
||||||
// Check if default value is already quoted
|
// Check if default value is already quoted
|
||||||
|
defaultvalue = defaultvalue.trim();
|
||||||
if(defaultvalue.startsWith("'") && defaultvalue.endsWith("'"))
|
if(defaultvalue.startsWith("'") && defaultvalue.endsWith("'"))
|
||||||
defaultvalue = defaultvalue.substring(1, defaultvalue.length() - 1);
|
defaultvalue = defaultvalue.substring(1, defaultvalue.length() - 1);
|
||||||
/*
|
|
||||||
if (defaultvalue.equalsIgnoreCase("NULL")) {
|
|
||||||
DDL += sqlStatement.substring(0, begin_col
|
|
||||||
- action.length())
|
|
||||||
+ " ALTER COLUMN "
|
|
||||||
+ column
|
|
||||||
+ " SET DEFAULT "
|
|
||||||
+ defaultvalue + "; ";
|
|
||||||
} else {
|
|
||||||
// Check if default value is already quoted, no need to double quote
|
|
||||||
if(defaultvalue.startsWith("'") && defaultvalue.endsWith("'"))
|
|
||||||
{
|
|
||||||
DDL += sqlStatement.substring(0, begin_col
|
|
||||||
- action.length())
|
|
||||||
+ " ALTER COLUMN "
|
|
||||||
+ column
|
|
||||||
+ " SET DEFAULT "
|
|
||||||
+ defaultvalue + "; ";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DDL += sqlStatement.substring(0, begin_col
|
|
||||||
- action.length())
|
|
||||||
+ " ALTER COLUMN "
|
|
||||||
+ column
|
|
||||||
+ " SET DEFAULT '"
|
|
||||||
+ defaultvalue + "'; ";
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
if (rest != null && rest.toUpperCase().indexOf("NOT NULL") >= 0)
|
if (rest != null && rest.toUpperCase().indexOf("NOT NULL") >= 0)
|
||||||
nullclause = "NOT NULL";
|
nullclause = "NOT NULL";
|
||||||
else if (rest != null && rest.toUpperCase().indexOf("NULL") >= 0)
|
else if (rest != null && rest.toUpperCase().indexOf("NULL") >= 0)
|
||||||
nullclause = "NULL";
|
nullclause = "NULL";
|
||||||
/*
|
|
||||||
DDL += sqlStatement.substring(0, begin_col - action.length())
|
|
||||||
+ " ALTER COLUMN " + column + " SET " + rest.trim()
|
|
||||||
+ ";";*/
|
|
||||||
// return DDL;
|
// return DDL;
|
||||||
}
|
}
|
||||||
else if ( rest != null && rest.toUpperCase().indexOf("NOT NULL") >= 0 ) {
|
else if ( rest != null && rest.toUpperCase().indexOf("NOT NULL") >= 0 ) {
|
||||||
nullclause = "NOT NULL";
|
nullclause = "NOT NULL";
|
||||||
/*
|
|
||||||
DDL += sqlStatement.substring(0, begin_col - action.length())
|
|
||||||
+ " ALTER COLUMN " + column + " SET " + rest.trim()
|
|
||||||
+ ";";*/
|
|
||||||
}
|
}
|
||||||
else if ( rest != null && rest.toUpperCase().indexOf("NULL") >= 0) {
|
else if ( rest != null && rest.toUpperCase().indexOf("NULL") >= 0) {
|
||||||
nullclause = "NULL";
|
nullclause = "NULL";
|
||||||
/*
|
|
||||||
DDL += sqlStatement.substring(0, begin_col - action.length())
|
|
||||||
+ " ALTER COLUMN " + column + " DROP NOT NULL"
|
|
||||||
+ ";";*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DDL = "insert into t_alter_column values('";
|
DDL = "insert into t_alter_column values('";
|
||||||
|
|
|
@ -84,6 +84,16 @@ public final class Convert_PostgreSQLTest extends TestCase{
|
||||||
sqe = "insert into t_alter_column values('sometablename','someColumnName','VARCHAR(64)',null,null)";
|
sqe = "insert into t_alter_column values('sometablename','someColumnName','VARCHAR(64)',null,null)";
|
||||||
r = convert.convert(sql);
|
r = convert.convert(sql);
|
||||||
assertEquals(sqe, r[0].trim());
|
assertEquals(sqe, r[0].trim());
|
||||||
|
|
||||||
|
sql = "ALTER TABLE S_Resource MODIFY IsActive CHAR(1) DEFAULT 'Y'";
|
||||||
|
sqe = "insert into t_alter_column values('s_resource','IsActive','CHAR(1)',null,'Y')";
|
||||||
|
r = convert.convert(sql);
|
||||||
|
assertEquals(sqe, r[0].trim());
|
||||||
|
|
||||||
|
sql = "ALTER TABLE PP_Order_NodeNext MODIFY PP_Order_NodeNext_ID NULL";
|
||||||
|
sqe = "insert into t_alter_column values('pp_order_nodenext','PP_Order_NodeNext_ID',null,'NULL',null)";
|
||||||
|
r = convert.convert(sql);
|
||||||
|
assertEquals(sqe, r[0].trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert.recoverQuotedStrings() error on strings with "<-->" - teo_sarca [ 1705768 ]
|
// Convert.recoverQuotedStrings() error on strings with "<-->" - teo_sarca [ 1705768 ]
|
||||||
|
|
Loading…
Reference in New Issue