Convert PostgreSQL cannot translate defaults with spaces
Description
Discovered trying to set " CO" as default to AD_Role.UserLevel In this case the exception thrown is:
11:35:45.329===========> ColumnSync.process: String index out of range: -1 [95]
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1949)
at org.compiere.dbPort.Convert_PostgreSQL.convertDDL(Convert_PostgreSQL.java:1110)
at org.compiere.dbPort.Convert_PostgreSQL.convertStatement(Convert_PostgreSQL.java:128)
at org.compiere.dbPort.Convert.convertIt(Convert.java:263)
at org.compiere.dbPort.Convert.convert(Convert.java:236)
at org.compiere.db.DB_PostgreSQL.convertStatement(DB_PostgreSQL.java:311)
at org.compiere.db.PreparedStatementProxy.<init>(PreparedStatementProxy.java:40)
at org.compiere.db.ProxyFactory.newCPreparedStatement(ProxyFactory.java:56)
at org.compiere.util.DB.executeUpdate(DB.java:1012)
at org.compiere.util.DB.executeUpdate(DB.java:922)
at org.compiere.util.DB.executeUpdate(DB.java:908)
at org.compiere.process.ColumnSync.doIt(ColumnSync.java:135)
Tested setting default "TEST SPACE" on C_BPartner.Name2 and the error is different in this case:
18:37:08.929===========> DB.executeUpdate: INSERT INTO t_alter_column values('c_bpartner','Name2','VARCHAR(60)',null,''TEST') [SvrProcess_fd6bfbec-d6b8-4e69-bb8c-86cb5f56d5d7] [282]
org.postgresql.util.PSQLException: ERROR: syntax error at or near "TEST"
Position: 77; State=42601; ErrorCode=0
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.compiere.db.StatementProxy.invoke(StatementProxy.java:125)
at $Proxy0.executeUpdate(Unknown Source)
at org.compiere.util.DB.executeUpdate(DB.java:1027)
at org.compiere.util.DB.executeUpdate(DB.java:922)
at org.compiere.util.DB.executeUpdate(DB.java:908)
at org.compiere.process.ColumnSync.doIt(ColumnSync.java:127)
Environment
None
Activity
Carlos Ruiz
December 18, 2013 at 3:58 PM
Triaging as not needed after 447 days - as the workaround is the most used case mostly nobody notice this, marking a potential idea in case we want to fix it later.
Discovered trying to set " CO" as default to AD_Role.UserLevel
In this case the exception thrown is:
11:35:45.329===========> ColumnSync.process: String index out of range: -1 [95] java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1949) at org.compiere.dbPort.Convert_PostgreSQL.convertDDL(Convert_PostgreSQL.java:1110) at org.compiere.dbPort.Convert_PostgreSQL.convertStatement(Convert_PostgreSQL.java:128) at org.compiere.dbPort.Convert.convertIt(Convert.java:263) at org.compiere.dbPort.Convert.convert(Convert.java:236) at org.compiere.db.DB_PostgreSQL.convertStatement(DB_PostgreSQL.java:311) at org.compiere.db.PreparedStatementProxy.<init>(PreparedStatementProxy.java:40) at org.compiere.db.ProxyFactory.newCPreparedStatement(ProxyFactory.java:56) at org.compiere.util.DB.executeUpdate(DB.java:1012) at org.compiere.util.DB.executeUpdate(DB.java:922) at org.compiere.util.DB.executeUpdate(DB.java:908) at org.compiere.process.ColumnSync.doIt(ColumnSync.java:135)
Tested setting default "TEST SPACE" on C_BPartner.Name2 and the error is different in this case:
18:37:08.929===========> DB.executeUpdate: INSERT INTO t_alter_column values('c_bpartner','Name2','VARCHAR(60)',null,''TEST') [SvrProcess_fd6bfbec-d6b8-4e69-bb8c-86cb5f56d5d7] [282] org.postgresql.util.PSQLException: ERROR: syntax error at or near "TEST" Position: 77; State=42601; ErrorCode=0 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105) at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.compiere.db.StatementProxy.invoke(StatementProxy.java:125) at $Proxy0.executeUpdate(Unknown Source) at org.compiere.util.DB.executeUpdate(DB.java:1027) at org.compiere.util.DB.executeUpdate(DB.java:922) at org.compiere.util.DB.executeUpdate(DB.java:908) at org.compiere.process.ColumnSync.doIt(ColumnSync.java:127)