我试图在日期(documentation for date)
上查询记录过滤select * from InstallationFee where infinite OR (date() >= dateFrom and date() <= dateTo)
查询在工作室中返回以下错误:
java.lang.ClassCastException: com.orientechnologies.orient.core.sql.filter.OSQLFilterItemField cannot be cast to com.orientechnologies.orient.core.sql.filter.OSQLFilterCondition
这是JAVA api中的堆栈跟踪
com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.select * from InstallationFee where (infinite OR date() >= dateFrom and date() <= dateTo)
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.executeCommand(OAbstractPaginatedStorage.java:1190)
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.command(OAbstractPaginatedStorage.java:1173)
at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:71)
at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:85)
at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:33)
at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.command(ONetworkProtocolBinary.java:1178)
at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:385)
at com.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.execute(OBinaryNetworkProtocolAbstract.java:216)
at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:65)
Caused by: java.lang.ClassCastException: com.orientechnologies.orient.core.sql.filter.OSQLFilterItemField cannot be cast to com.orientechnologies.orient.core.sql.filter.OSQLFilterCondition
at com.orientechnologies.orient.core.sql.OFilterAnalyzer.analyzeUnion(OFilterAnalyzer.java:195)
at com.orientechnologies.orient.core.sql.OFilterAnalyzer.analyzeOrFilterBranch(OFilterAnalyzer.java:80)
at com.orientechnologies.orient.core.sql.OFilterAnalyzer.analyzeMainCondition(OFilterAnalyzer.java:58)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.searchForIndexes(OCommandExecutorSQLSelect.java:1454)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.searchInClasses(OCommandExecutorSQLSelect.java:765)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLResultsetAbstract.assignTarget(OCommandExecutorSQLResultsetAbstract.java:194)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.assignTarget(OCommandExecutorSQLSelect.java:438)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.executeSearch(OCommandExecutorSQLSelect.java:420)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.execute(OCommandExecutorSQLSelect.java:391)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.execute(OCommandExecutorSQLDelegate.java:64)
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.executeCommand(OAbstractPaginatedStorage.java:1184)
我在工作室尝试了不同的方法,但都是由于上面提到的错误而导致的。以下是一些:
使用sysdate
select * from InstallationFee where infinite OR (sysdate("yyyy-MM-dd") >= dateFrom and sysdate("yyyy-MM-dd") <= dateTo)
使用between
(documentation)
select * from InstallationFee where infinite OR date("yyyy-MM-dd") between dateFrom and dateTo)
我错过了什么吗?或者有解决这个问题的方法吗?
答案 0 :(得分:2)
我认为错误来自:
... where infinite ...
应该是:
... where infinite = true ...