NXQL IN operator currently only supports array of String, should support array
of Integer, Long etc; functionality missing in jdbc/JDBCMapper
---------------------------------------------------------------------------------------------------------------------------------------------
Key: NXP-8012
URL: https://jira.nuxeo.com/browse/NXP-8012
Project: Nuxeo Enterprise Platform
Issue Type: Bug
Components: Core SQL Storage
Affects Versions: 5.4.2, 5.4.1
Reporter: Alf Hogemark
Priority: Major
I have a NXQL query which contains a "WHERE someid in ?", and then I use the
QueryModel.getDocuments to execute the query.
The datatype of someid in the database is not String/VARCHAR, but an
INTEGER/LONG.
I am not able to execute this query, since the NXQL is not expanded into proper
JDBC.
Long[] ids;
Object[] params = new Object[] { section, ids};
DocumentModelList res = qm.getDocuments(session, params);
The problem is that when this is executed, the
nuxeo-core-storage-sql/nuxeo-core-storage-sql/src/main/java/org/nuxeo/ecm/core/storage/sql/jdbc/JDBCMapper.java
just does a "setObject" on the PreparedStatement that is being used.
If I try to pass in a String[] to the qm.getDocuments, then the query is
executed, but then PostgreSQL complains :
Exception: org.postgresql.util.PSQLException. message: ERROR: operator does not
exist: bigint = character varying
The
nuxeo-core-storage-sql/nuxeo-core-storage-sql/src/main/java/org/nuxeo/ecm/core/storage/sql/jdbc/JDBCMapper.java
contains the following code :
for (Object object : q.selectParams) {
if (object instanceof Calendar) {
Calendar cal = (Calendar) object;
Timestamp ts = new Timestamp(cal.getTimeInMillis());
ps.setTimestamp(i++, ts, cal); // cal passed for timezone
} else if (object instanceof String[]) {
Array array = sqlInfo.dialect.createArrayOf(Types.VARCHAR,
(Object[]) object, connection);
ps.setArray(i++, array);
} else {
ps.setObject(i++, object);
}
}
This code should be improved, to check for "object instanceof Integer[]",
"object instanceof Long[]" etc, and issue the correct ps.setArray method call.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets